From baed140abfe80abe9aba51c4e850d34a9ab428db Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 18 Aug 2022 06:12:44 +0000 Subject: [PATCH 001/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8f5aeaf..a0148e8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 11f77b8c56dd892789cadcb4bcb890e125ea4cfa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 18 Aug 2022 06:58:48 +0000 Subject: [PATCH 002/181] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .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 | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- branches.md | 53 - ctor/README.md | 126 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 30 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 -- to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 53 files changed, 2717 insertions(+), 4347 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +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 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 27daa06..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/function) 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 29bf533..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@v2 - 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 a7a7f51..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.9.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 be33dba..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/function) 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 39b1613..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@v2 - 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 7ca169c..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: '0 8 * * 6' - - # 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@v2 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - 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@v2 - 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@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# 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@v2 - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -105,7 +104,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 69117e8..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,126 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - - - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index 69819a0..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index ced310b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Function = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..375da91 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ad1a8cb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index a0148e8..c21abf2 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..77d3de7 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index e2470a8..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by`Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 135edc951082a39c17ff469dbdaacccbd803353c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 23 Aug 2022 06:35:50 +0000 Subject: [PATCH 003/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8f5aeaf..a0148e8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 0debb3cf5d7c2281eb99e950b986edef90df5378 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 23 Aug 2022 06:42:43 +0000 Subject: [PATCH 004/181] Remove files --- index.d.ts | 44 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2738 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 567ae9b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,44 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * TODO - */ - Function: typeof Function; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 375da91..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ad1a8cb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 77d3de7..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 0fc17b0f0f3395de52179f4c69b82ddbdfc7dc4d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 23 Aug 2022 06:45:20 +0000 Subject: [PATCH 005/181] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .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 | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- branches.md | 53 - ctor/README.md | 126 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 30 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 -- to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 53 files changed, 2717 insertions(+), 4347 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +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 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 27daa06..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/function) 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 29bf533..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@v2 - 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 a7a7f51..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.9.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 be33dba..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/function) 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 39b1613..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@v2 - 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 7ca169c..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: '0 8 * * 6' - - # 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@v2 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - 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@v2 - 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@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# 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@v2 - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -105,7 +104,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 69117e8..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,126 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - - - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index 69819a0..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index ced310b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Function = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..375da91 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ad1a8cb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index a0148e8..c21abf2 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..710d59c --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From c91b83f31df3b394f8f4154203fd1e202e684854 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 24 Aug 2022 10:10:27 +0000 Subject: [PATCH 006/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8f5aeaf..a0148e8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 7ed7ebe60453f06516a2b1130a4fbbad068d487e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 24 Aug 2022 10:36:09 +0000 Subject: [PATCH 007/181] Remove files --- index.d.ts | 44 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2738 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 567ae9b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,44 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * TODO - */ - Function: typeof Function; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 375da91..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ad1a8cb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 710d59c..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From e51b48f99c14272a60f971418e941d9350b47e6e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 24 Aug 2022 10:39:32 +0000 Subject: [PATCH 008/181] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .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 | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- branches.md | 53 - ctor/README.md | 120 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 30 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 -- to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 53 files changed, 2717 insertions(+), 4341 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +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 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 27daa06..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/function) 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 29bf533..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@v2 - 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 a7a7f51..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.9.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 be33dba..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/function) 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 39b1613..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@v2 - 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 7ca169c..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: '0 8 * * 6' - - # 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@v2 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - 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@v2 - 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@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# 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@v2 - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -105,7 +104,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index ac67ec1..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,120 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index 69819a0..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..375da91 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ad1a8cb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index a0148e8..c21abf2 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c989366 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 4c0d81e64853f1658ffca4794c498f565bbf8ce9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Aug 2022 02:42:06 +0000 Subject: [PATCH 009/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8f5aeaf..a0148e8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From bf1227031970f140cfa43d914622c1208292b8d2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Aug 2022 03:07:41 +0000 Subject: [PATCH 010/181] Remove files --- index.d.ts | 44 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2738 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 567ae9b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,44 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * TODO - */ - Function: typeof Function; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 375da91..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ad1a8cb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c989366..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From c09a4e44f0ad632866f2966085492b17f703b4be Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Aug 2022 03:10:45 +0000 Subject: [PATCH 011/181] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .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 | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 30 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 -- to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 53 files changed, 2717 insertions(+), 4453 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +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 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 27daa06..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/function) 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 29bf533..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@v2 - 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 a7a7f51..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.9.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 be33dba..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/function) 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 39b1613..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@v2 - 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 7ca169c..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: '0 8 * * 6' - - # 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@v2 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - 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@v2 - 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@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# 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@v2 - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -105,7 +104,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index df617e4..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function witht he given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -functiona add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index 69819a0..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..375da91 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ad1a8cb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index a0148e8..c21abf2 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4b5db26 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 4d07e98e9de0015b88a4a5dc831801b4b5c66a9a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Aug 2022 21:20:50 +0000 Subject: [PATCH 012/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8f5aeaf..a0148e8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 37c0baf8b5a2cef1589593ff799112ecaf668097 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Aug 2022 21:50:01 +0000 Subject: [PATCH 013/181] Remove files --- index.d.ts | 44 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2738 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 567ae9b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,44 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * TODO - */ - Function: typeof Function; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 375da91..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ad1a8cb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4b5db26..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 7906087fd10a56f6850e4561c3ab35c353b813d3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Aug 2022 21:52:46 +0000 Subject: [PATCH 014/181] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .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 | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 30 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 -- to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 53 files changed, 2717 insertions(+), 4453 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +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 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 27daa06..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/function) 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 29bf533..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@v2 - 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 a7a7f51..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.9.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 be33dba..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/function) 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 39b1613..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@v2 - 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 7ca169c..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: '0 8 * * 6' - - # 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@v2 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - 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@v2 - 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@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# 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@v2 - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index df617e4..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function witht he given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -functiona add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index 69819a0..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..375da91 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ad1a8cb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index a0148e8..c21abf2 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ad88964 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 7f6bf190e3ebce7e5dba276f8fbd631c61dfb45f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 04:27:22 +0000 Subject: [PATCH 015/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8f5aeaf..a0148e8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 0981dcf132adecfe68cc6d4011fd3669e354dbbf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 18:49:54 +0000 Subject: [PATCH 016/181] Remove files --- index.d.ts | 44 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2738 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 567ae9b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,44 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * TODO - */ - Function: typeof Function; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 375da91..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ad1a8cb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ad88964..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From b5307fcfe584fd940db9fa19480194073a5a5cfe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 18:53:09 +0000 Subject: [PATCH 017/181] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .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 | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 30 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 -- to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 54 files changed, 2717 insertions(+), 4470 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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/.keepalive b/.github/.keepalive deleted file mode 100644 index 5507505..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T00:33:45.094Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 29bf533..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@v2 - 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 a7a7f51..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.9.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 be33dba..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/function) 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 39b1613..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@v2 - 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 7ca169c..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: '0 8 * * 6' - - # 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@v2 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - 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@v2 - 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@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# 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@v2 - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index df617e4..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function witht he given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -functiona add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index 69819a0..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..375da91 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ad1a8cb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index a0148e8..c21abf2 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c5127c2 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From a58be39d1edca5d6626016ae68b02e1bd7f25fed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Sep 2022 11:45:41 +0000 Subject: [PATCH 018/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8f5aeaf..a0148e8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 7cddb2769bac5c0a4b14fa486b3d9a5f17f11fff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Sep 2022 12:18:22 +0000 Subject: [PATCH 019/181] Remove files --- index.d.ts | 44 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2738 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 567ae9b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,44 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * TODO - */ - Function: typeof Function; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 375da91..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ad1a8cb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c5127c2..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 65265b200a693df88d06f31d043ac39effd5e844 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Sep 2022 12:21:11 +0000 Subject: [PATCH 020/181] 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 | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 30 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 -- to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 53 files changed, 2717 insertions(+), 4469 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 29bf533..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@v2 - 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 a7a7f51..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.9.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 be33dba..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/function) 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 39b1613..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@v2 - 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 7ca169c..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: '0 8 * * 6' - - # 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@v2 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - 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@v2 - 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@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# 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@v2 - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index 69819a0..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..375da91 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ad1a8cb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index a0148e8..c21abf2 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9dffaac --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From f03c9a0e2a84bb134a36fb8630e5ce2281f23bac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 01:04:53 +0000 Subject: [PATCH 021/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8f5aeaf..a0148e8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From f4092c11f2d4227bf3709ce1b715925e52cf75ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 17:31:59 +0000 Subject: [PATCH 022/181] Remove files --- index.d.ts | 44 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2738 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 567ae9b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,44 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * TODO - */ - Function: typeof Function; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 375da91..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ad1a8cb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9dffaac..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 75ad402781d6b9a55b007dd023e5fd6110042d62 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 17:34:36 +0000 Subject: [PATCH 023/181] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .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 | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 30 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 -- to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 54 files changed, 2717 insertions(+), 4470 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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/.keepalive b/.github/.keepalive deleted file mode 100644 index dcbca6a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T00:57:37.457Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 29bf533..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@v2 - 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 a7a7f51..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.9.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 be33dba..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/function) 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 39b1613..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@v2 - 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 7ca169c..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: '0 8 * * 6' - - # 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@v2 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - 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@v2 - 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@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# 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@v2 - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index 69819a0..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..375da91 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ad1a8cb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index a0148e8..c21abf2 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4f899e4 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 42eaedbc70b3a9779b15d0d5b2cb273435374190 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 7 Oct 2022 16:06:30 +0000 Subject: [PATCH 024/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8f5aeaf..a0148e8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From e2a40a52c4f0eb4b8dbf4dd3556574a4bf9f0478 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 7 Oct 2022 16:11:10 +0000 Subject: [PATCH 025/181] Remove files --- index.d.ts | 44 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2738 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 567ae9b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,44 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * TODO - */ - Function: typeof Function; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 375da91..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ad1a8cb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4f899e4..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 6a2b6e672e703455392d1d6139480aa8f35d224b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 7 Oct 2022 16:14:42 +0000 Subject: [PATCH 026/181] 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 | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 -- ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 -- to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 53 files changed, 2717 insertions(+), 4582 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 29bf533..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@v2 - 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 a7a7f51..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.9.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 be33dba..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/function) 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 39b1613..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@v2 - 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 7ca169c..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: '0 8 * * 6' - - # 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@v2 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - 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@v2 - 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@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# 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@v2 - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..375da91 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ad1a8cb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index a0148e8..c21abf2 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..11fdbbc --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 02ef6405a61aff3925034f778cb8f99b4ad55467 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 11 Oct 2022 22:04:20 +0000 Subject: [PATCH 027/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8f5aeaf..a0148e8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 107597903d6b706f4d98c695e5915a53df3d1ff0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 11 Oct 2022 22:55:13 +0000 Subject: [PATCH 028/181] Remove files --- index.d.ts | 44 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2738 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 567ae9b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,44 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * TODO - */ - Function: typeof Function; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 375da91..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ad1a8cb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 11fdbbc..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 416089c4712a8bdb7fa5317647aece93cba878de Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 11 Oct 2022 22:58:54 +0000 Subject: [PATCH 029/181] 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 | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 -- ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 -- to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 53 files changed, 2717 insertions(+), 4582 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 29bf533..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@v2 - 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 a7a7f51..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.9.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 be33dba..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/function) 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 39b1613..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@v2 - 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 7ca169c..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: '0 8 * * 6' - - # 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@v2 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - 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@v2 - 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@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# 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@v2 - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # 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@v2 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..375da91 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ad1a8cb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index a0148e8..c21abf2 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0b9a6bc --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 3f0f52cf82ea3a028c871878467e60517db42cad Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:42:17 +0000 Subject: [PATCH 030/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8f5aeaf..a0148e8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 1b933e46b18bf94aedbac2c43079a0a8a6523b31 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 19:38:34 +0000 Subject: [PATCH 031/181] Remove files --- index.d.ts | 92 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2786 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 78f7e1c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 375da91..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ad1a8cb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,IEtBtBE,EAAA,GAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0b9a6bc..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 387311efcb65a7f54dd42d27ab9de619d2bcb964 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 19:41:22 +0000 Subject: [PATCH 032/181] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .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 | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 54 files changed, 4072 insertions(+), 4583 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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/.keepalive b/.github/.keepalive deleted file mode 100644 index a7fc9cb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T00:46:10.075Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 be33dba..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/function) 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 df50bb0..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: '39 3 * * 5' - - # 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 9113bfe..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 - - # 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 - - # 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..375da91 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d08988a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,EACtB,EEvBAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index a0148e8..c21abf2 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..12fa47a --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 6d690170608427d70a9cd964c8a57689afcd2b15 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 3 Nov 2022 23:23:53 +0000 Subject: [PATCH 033/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8f5aeaf..a0148e8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From fccb1d5927728d0861e67bd90b46629602ba75bb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 06:22:44 +0000 Subject: [PATCH 034/181] Remove files --- index.d.ts | 92 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4141 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 78f7e1c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 375da91..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d08988a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,EACtB,EEvBAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 12fa47a..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 55615c0ac3fc51edd58710a1b5c03ca925ffb9fe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 06:27:47 +0000 Subject: [PATCH 035/181] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .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 | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 54 files changed, 4072 insertions(+), 4604 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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/.keepalive b/.github/.keepalive deleted file mode 100644 index 632918a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T20:48:21.437Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 be33dba..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/function) 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 df50bb0..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: '39 3 * * 5' - - # 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 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +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: - -# 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..375da91 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d08988a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,EACtB,EEvBAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index a0148e8..c21abf2 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3eb5cd3 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From c6d83678104bdc4cc46e0ba5b1443616e7a18137 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 00:40:33 +0000 Subject: [PATCH 036/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b45eba8..82e5b08 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 86f67f95bdd843cf27559c278211d2481de3b386 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 10:08:19 +0000 Subject: [PATCH 037/181] Remove files --- index.d.ts | 92 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4141 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 78f7e1c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 375da91..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var t=Function,i=Function.prototype.toString;var o=function(n){return i.call(n)},r={};n(r,"Function",t),n(r,"function2string",o);export{t as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d08988a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../ctor/lib/index.js","../to-string/lib/main.js","../to-string/lib/index.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property' ;\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["lib","Function","fcn2str","prototype","toString","fcn","call","ns","setReadOnly","function2string"],"mappings":";;mGAsCA,ICGAA,EDHUC,SEfNC,EAAUD,SAASE,UAAUC,SAyCjC,ICrBAJ,EDcA,SAA0BK,GACzB,OAAOH,EAAQI,KAAMD,EACtB,EEvBAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAN,GAUAO,EAAAD,EAAA,kBAAAE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3eb5cd3..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 999340ae1a1b844a1d95773d9ab5ed2f9d32c9a3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 10:11:04 +0000 Subject: [PATCH 038/181] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .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 | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 183 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 54 files changed, 4072 insertions(+), 4609 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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/.keepalive b/.github/.keepalive deleted file mode 100644 index c4e06b9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T00:40:00.551Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 be33dba..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/function) 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 df50bb0..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: '39 3 * * 5' - - # 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 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +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: - -# 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5694468 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a4526e6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 82e5b08..c21abf2 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "2.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7bb0194 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 3e94c8ef1b7a40a7a0e8caf79e2e6218c35b787a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 03:22:21 +0000 Subject: [PATCH 039/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 84a2659..22c6979 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 3dac1651d8d3a1a67ea4baee886bd1bfdff4ae71 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 13:24:37 +0000 Subject: [PATCH 040/181] Remove files --- index.d.ts | 92 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4141 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 78f7e1c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5694468..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a4526e6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7bb0194..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 8379fe51737329941c8ae0ef140b052413ee4592 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 13:28:29 +0000 Subject: [PATCH 041/181] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .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 | 791 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 54 files changed, 4072 insertions(+), 4620 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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/.keepalive b/.github/.keepalive deleted file mode 100644 index be6db7f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T00:35:07.500Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 be33dba..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/function) 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 df50bb0..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: '39 3 * * 5' - - # 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 f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +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 - -# 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a841c75 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a4526e6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 22c6979..c21abf2 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "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", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4c39014 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From faae8e0b7aa68e67d9426f7d7a927f21add524aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 03:19:34 +0000 Subject: [PATCH 042/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 84a2659..22c6979 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From e49b8acbdc84b726db31b4336c598f92492da768 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 11:06:03 +0000 Subject: [PATCH 043/181] Remove files --- index.d.ts | 92 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4141 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 78f7e1c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a841c75..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a4526e6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4c39014..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From d8fc956245e36bbb646f659b5ee1da72b05626f3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 11:09:01 +0000 Subject: [PATCH 044/181] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .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 | 791 --- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 54 files changed, 6205 insertions(+), 4620 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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/.keepalive b/.github/.keepalive deleted file mode 100644 index dae8835..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T00:39:13.933Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 be33dba..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/function) 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 df50bb0..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: '39 3 * * 5' - - # 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 f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +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 - -# 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a841c75 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a4526e6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 22c6979..c21abf2 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "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", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e437c26 --- /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 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 906d2c88e1d6b22a226ceea9ce27f3a5f13c26dc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Feb 2023 04:21:25 +0000 Subject: [PATCH 045/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4574169..bd652f4 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From f2d7c16cc671571898daef640745ee84c8cb0e1a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Feb 2023 04:24:22 +0000 Subject: [PATCH 046/181] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6274 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 78f7e1c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a841c75..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a4526e6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e437c26..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 282e690044dcccd24dbfabe570312ff7327645ff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Feb 2023 04:27:21 +0000 Subject: [PATCH 047/181] 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 | 791 --- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 53 files changed, 6205 insertions(+), 4619 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 be33dba..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/function) 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 df50bb0..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: '39 3 * * 5' - - # 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 f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +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 - -# 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index a4a34b2..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/function" -click B href "https://github.com/stdlib-js/function/tree/main" -click C href "https://github.com/stdlib-js/function/tree/production" -click D href "https://github.com/stdlib-js/function/tree/esm" -click E href "https://github.com/stdlib-js/function/tree/deno" -click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a841c75 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a4526e6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index bd652f4..3fdae11 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench", - "@stdlib/blas": "github:stdlib-js/blas", - "@stdlib/math": "github:stdlib-js/math", - "@stdlib/ndarray": "github:stdlib-js/ndarray", - "@stdlib/random": "github:stdlib-js/random", - "@stdlib/string": "github:stdlib-js/string", - "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", "standard", @@ -79,4 +27,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..88d79f4 --- /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 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 627d10a7aa3d93384c6224d252530173ab4ecfdc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Feb 2023 04:28:45 +0000 Subject: [PATCH 048/181] Update README.md for ESM bundle v0.0.1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 18ae030..d0d1680 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,13 @@ limitations under the License. ## Usage ```javascript -import ns from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@esm/index.mjs'; +import ns from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@v0.0.1-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { Function, function2string } from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@esm/index.mjs'; +import { Function, function2string } from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@v0.0.1-esm/index.mjs'; ``` #### ns @@ -81,7 +81,7 @@ The namespace contains the following: - - - - From 0d60275eaf53f022ad3fd994fb7c94d8124294b3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 02:11:12 +0000 Subject: [PATCH 052/181] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 236 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 54 files changed, 6205 insertions(+), 4755 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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/.keepalive b/.github/.keepalive deleted file mode 100644 index 88aab18..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T00:47:40.445Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 be33dba..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/function) 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 df50bb0..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: '39 3 * * 5' - - # 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a841c75 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a4526e6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index ecf00e9..a3de6c5 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..17e4b97 --- /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 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 646fbb540d0ad974f3aea04ae6dbcbee719161bb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 00:57:20 +0000 Subject: [PATCH 053/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 16224db..ecf00e9 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 68e0663e76a4d4f42aa96a0694c39e3b47c358c0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 01:59:15 +0000 Subject: [PATCH 054/181] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6274 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 78f7e1c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a841c75..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a4526e6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 17e4b97..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3e0a8a413a24c4a00f8e073b36de3fa6fab2c94b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 02:03:04 +0000 Subject: [PATCH 055/181] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .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 | 41 +- branches.md | 53 - ctor/README.md | 232 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 54 files changed, 6205 insertions(+), 4761 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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/.keepalive b/.github/.keepalive deleted file mode 100644 index 7fcb64a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-04-01T00:45:46.171Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 be33dba..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/function) 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 df50bb0..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: '39 3 * * 5' - - # 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a841c75 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a4526e6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index ecf00e9..a3de6c5 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..9a6b4cf --- /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 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 3319f34e6c82c329dac6b6180a8fa2099bdd40b3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 00:56:14 +0000 Subject: [PATCH 056/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 16224db..ecf00e9 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 779ffc1b8576c91c81f7326e7d4d0f1cb8586fde Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 01:56:41 +0000 Subject: [PATCH 057/181] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6274 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 78f7e1c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a841c75..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a4526e6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9a6b4cf..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 104ce80a8380a0429e93a81e20a5849a7a6250c8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 01:59:43 +0000 Subject: [PATCH 058/181] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .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 | 41 +- branches.md | 53 - ctor/README.md | 232 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 54 files changed, 6205 insertions(+), 4761 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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/.keepalive b/.github/.keepalive deleted file mode 100644 index 7bff0bb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-05-01T00:45:01.608Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 be33dba..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/function) 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 df50bb0..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: '39 3 * * 5' - - # 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a841c75 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a4526e6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index ecf00e9..a3de6c5 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..8c2ad05 --- /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 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 86142e4e49c96b2a84a4fa4dff8968101f849b97 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 01:04:06 +0000 Subject: [PATCH 059/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 16224db..ecf00e9 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From de22ad394689f8e086bddb86f1f67150edcd9043 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 02:02:18 +0000 Subject: [PATCH 060/181] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6274 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 78f7e1c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a841c75..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a4526e6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8c2ad05..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c08071ab74aa682f333d77a9df60aa844e7afaf2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 02:05:20 +0000 Subject: [PATCH 061/181] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .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 | 41 +- branches.md | 53 - ctor/README.md | 232 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 54 files changed, 6205 insertions(+), 4761 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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/.keepalive b/.github/.keepalive deleted file mode 100644 index 29b0de7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T00:52:56.565Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 be33dba..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/function) 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 df50bb0..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: '39 3 * * 5' - - # 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a841c75 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a4526e6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index ecf00e9..a3de6c5 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..b82390e --- /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 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 24f4605a8a264350244fd9de95778671791e81f6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 01:02:37 +0000 Subject: [PATCH 062/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 16224db..ecf00e9 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 15b9e205b7e9687e2f96759447098263061765f7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 02:06:49 +0000 Subject: [PATCH 063/181] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6274 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 78f7e1c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a841c75..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a4526e6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b82390e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4c3c934e2ab11dd0887868df9979ae0cbf1ab08e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 02:10:09 +0000 Subject: [PATCH 064/181] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .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 | 41 +- branches.md | 53 - ctor/README.md | 232 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 54 files changed, 6205 insertions(+), 4761 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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/.keepalive b/.github/.keepalive deleted file mode 100644 index 2542e32..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T00:51:26.674Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 be33dba..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/function) 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 df50bb0..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: '39 3 * * 5' - - # 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index d7fb002..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index d7c5b36..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a841c75 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a4526e6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index ecf00e9..a3de6c5 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..f559eaf --- /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 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From d1097b0d5241bb215bb0cf5eeca48c2c4acecc64 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 23 Jul 2023 21:39:22 +0000 Subject: [PATCH 065/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 16224db..ecf00e9 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From e6f596558b12108d7188deba03999d5a81cd3bc9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 23 Jul 2023 21:39:49 +0000 Subject: [PATCH 066/181] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6274 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 78f7e1c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a841c75..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a4526e6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function;\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f559eaf..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6bbf2f3cfdd40b30fcc7ef052d4de52621b53b60 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 23 Jul 2023 21:42:49 +0000 Subject: [PATCH 067/181] 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 | 41 +- branches.md | 53 - ctor/README.md | 232 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 53 files changed, 6205 insertions(+), 4760 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 be33dba..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/function) 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 df50bb0..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: '39 3 * * 5' - - # 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a841c75 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..693fc05 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index ecf00e9..a3de6c5 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..ea0ea8e --- /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 62b8d8f..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 064d0ea37dd88795f8e5aeee5385edb7f59f7dc6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 01:00:22 +0000 Subject: [PATCH 068/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 16224db..ecf00e9 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 77fa08079f3de9f1aa005386f1d3a3636276d0e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 02:03:43 +0000 Subject: [PATCH 069/181] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6274 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 78f7e1c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a841c75..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 693fc05..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ea0ea8e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e391854dfc3098ff3d6d2d6a979a6c508e0c27b5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 02:07:35 +0000 Subject: [PATCH 070/181] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .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 | 41 +- branches.md | 53 - ctor/README.md | 232 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 54 files changed, 6205 insertions(+), 4761 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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/.keepalive b/.github/.keepalive deleted file mode 100644 index ba8d70d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T00:48:40.224Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 be33dba..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/function) 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 df50bb0..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: '39 3 * * 5' - - # 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 + + ```
@@ -112,7 +111,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index 7ddbdf7..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a841c75 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..693fc05 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index ecf00e9..a3de6c5 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..d2dcfca --- /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 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 6723b2a..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 2276083491efccc0160e9eea1fdf4aa71f3a0835 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 01:08:32 +0000 Subject: [PATCH 071/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 16224db..4a76f1d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From e86191676b964e646f2fdd5e6ddf2b1b88d34df1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 05:19:27 +0000 Subject: [PATCH 072/181] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6274 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 78f7e1c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 2.0 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a841c75..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 693fc05..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;mGAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d2dcfca..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 363239c7ff97353f96ae0538b445aa109d207cc8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 05:23:50 +0000 Subject: [PATCH 073/181] 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 | 41 +- branches.md | 53 - ctor/README.md | 232 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - dist/index.d.ts | 3 - dist/index.js | 11 - dist/index.js.map | 7 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 40 - test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 59 files changed, 6205 insertions(+), 4900 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 9e9f999..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T00:43:45.190Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 49a98a5..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/function) 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 5421fc6..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: '39 3 * * 5' - - # 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 + + ```
@@ -123,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 15e948f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ns from '../docs/types/index'; -export = ns; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d3ecab..0000000 --- a/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=t(function(y,i){ -var x=Function;i.exports=x -});var c=t(function(d,u){ -var f=s();u.exports=f -});var a=t(function(O,o){ -var F=Function.prototype.toString;function g(e){return F.call(e)}o.exports=g -});var v=t(function(R,p){ -var l=a();p.exports=l -});var q=require('@stdlib/utils/define-read-only-property/dist'),n={};q(n,"Function",c());q(n,"function2string",v());module.exports=n; -/** @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 398b6fe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../ctor/lib/main.js", "../ctor/lib/index.js", "../to-string/lib/main.js", "../to-string/lib/index.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils/define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nsetReadOnly( ns, 'Function', require( './../ctor' ) );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nsetReadOnly( ns, 'function2string', require( './../to-string' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAM,SAKVD,EAAO,QAAUC,IC3CjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAU,SAAS,UAAU,SAkCjC,SAASC,EAAiBC,EAAM,CAC/B,OAAOF,EAAQ,KAAME,CAAI,CAC1B,CAKAH,EAAO,QAAUE,IChEjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICjBjB,IAAIC,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,WAAY,GAAuB,EASpDD,EAAaC,EAAI,kBAAmB,GAA4B,EAKhE,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "Fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "require_main", "__commonJSMin", "exports", "module", "fcn2str", "function2string", "fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "setReadOnly", "ns"] -} diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9cf3c44 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.0-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 4a76f1d..a3de6c5 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..455c1f4 --- /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 02f9958..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 0e2ce71bea79b76589c6eeffcbc061b4fea16805 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 03:08:14 +0000 Subject: [PATCH 074/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 16224db..7695a97 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c4daaa0f56d41708695956aeb174b10ae32997de Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 07:15:48 +0000 Subject: [PATCH 075/181] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6274 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 6e83156..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 4.1 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9cf3c44..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.0-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 455c1f4..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c10e07be89dade5f940f20220368fb8a9fe17120 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 07:19:00 +0000 Subject: [PATCH 076/181] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - dist/index.d.ts | 3 - dist/index.js | 11 - dist/index.js.map | 7 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 40 - test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 58 files changed, 6205 insertions(+), 4899 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 49a98a5..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/function) 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 5421fc6..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: '39 3 * * 5' - - # 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 + + ```
@@ -123,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 15e948f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ns from '../docs/types/index'; -export = ns; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d3ecab..0000000 --- a/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=t(function(y,i){ -var x=Function;i.exports=x -});var c=t(function(d,u){ -var f=s();u.exports=f -});var a=t(function(O,o){ -var F=Function.prototype.toString;function g(e){return F.call(e)}o.exports=g -});var v=t(function(R,p){ -var l=a();p.exports=l -});var q=require('@stdlib/utils/define-read-only-property/dist'),n={};q(n,"Function",c());q(n,"function2string",v());module.exports=n; -/** @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 398b6fe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../ctor/lib/main.js", "../ctor/lib/index.js", "../to-string/lib/main.js", "../to-string/lib/index.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils/define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nsetReadOnly( ns, 'Function', require( './../ctor' ) );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nsetReadOnly( ns, 'function2string', require( './../to-string' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAM,SAKVD,EAAO,QAAUC,IC3CjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAU,SAAS,UAAU,SAkCjC,SAASC,EAAiBC,EAAM,CAC/B,OAAOF,EAAQ,KAAME,CAAI,CAC1B,CAKAH,EAAO,QAAUE,IChEjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICjBjB,IAAIC,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,WAAY,GAAuB,EASpDD,EAAaC,EAAI,kBAAmB,GAA4B,EAKhE,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "Fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "require_main", "__commonJSMin", "exports", "module", "fcn2str", "function2string", "fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "setReadOnly", "ns"] -} diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ee241a3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 7695a97..a3de6c5 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..6f3cad7 --- /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 02f9958..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 4ee2791a1dd9d6c8b2a8fece10e559a85c2e1465 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 01:05:30 +0000 Subject: [PATCH 077/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 16224db..7695a97 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0f54eec0d32d9bb23f5d9bd2107967517b229908 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 05:31:33 +0000 Subject: [PATCH 078/181] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6274 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 6e83156..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 4.1 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ee241a3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6f3cad7..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 92f7cb9142abe0171d12fd54f09bda87dfe34ab2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 05:36:03 +0000 Subject: [PATCH 079/181] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - dist/index.d.ts | 3 - dist/index.js | 11 - dist/index.js.map | 7 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 59 files changed, 6205 insertions(+), 4901 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 1d22a1e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T00:42:33.464Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 49a98a5..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/function) 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 5421fc6..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: '39 3 * * 5' - - # 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 + + ```
@@ -123,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 15e948f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ns from '../docs/types/index'; -export = ns; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d3ecab..0000000 --- a/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=t(function(y,i){ -var x=Function;i.exports=x -});var c=t(function(d,u){ -var f=s();u.exports=f -});var a=t(function(O,o){ -var F=Function.prototype.toString;function g(e){return F.call(e)}o.exports=g -});var v=t(function(R,p){ -var l=a();p.exports=l -});var q=require('@stdlib/utils/define-read-only-property/dist'),n={};q(n,"Function",c());q(n,"function2string",v());module.exports=n; -/** @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 398b6fe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../ctor/lib/main.js", "../ctor/lib/index.js", "../to-string/lib/main.js", "../to-string/lib/index.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils/define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nsetReadOnly( ns, 'Function', require( './../ctor' ) );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nsetReadOnly( ns, 'function2string', require( './../to-string' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAM,SAKVD,EAAO,QAAUC,IC3CjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAU,SAAS,UAAU,SAkCjC,SAASC,EAAiBC,EAAM,CAC/B,OAAOF,EAAQ,KAAME,CAAI,CAC1B,CAKAH,EAAO,QAAUE,IChEjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICjBjB,IAAIC,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,WAAY,GAAuB,EASpDD,EAAaC,EAAI,kBAAmB,GAA4B,EAKhE,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "Fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "require_main", "__commonJSMin", "exports", "module", "fcn2str", "function2string", "fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "setReadOnly", "ns"] -} diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ee241a3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 7695a97..a3de6c5 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..400f122 --- /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 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 78f9414482d201647c2e5835ae6bf15bd5796c17 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 20:55:58 +0000 Subject: [PATCH 080/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 16224db..7695a97 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f704135b7df05167039eefa44077c469ca144749 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 23:10:32 +0000 Subject: [PATCH 081/181] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6274 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 6e83156..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 4.1 - -/* tslint:disable:max-line-length */ -/* tslint:disable:max-file-line-count */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ee241a3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 400f122..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4eb4028b9946a1a9f097fda3a62b2415c3ac6a7b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 23:13:58 +0000 Subject: [PATCH 082/181] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - dist/index.d.ts | 3 - dist/index.js | 11 - dist/index.js.map | 7 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 58 files changed, 6205 insertions(+), 4900 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 49a98a5..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/function) 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 5421fc6..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: '39 3 * * 5' - - # 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 + + ```
@@ -123,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 15e948f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ns from '../docs/types/index'; -export = ns; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d3ecab..0000000 --- a/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=t(function(y,i){ -var x=Function;i.exports=x -});var c=t(function(d,u){ -var f=s();u.exports=f -});var a=t(function(O,o){ -var F=Function.prototype.toString;function g(e){return F.call(e)}o.exports=g -});var v=t(function(R,p){ -var l=a();p.exports=l -});var q=require('@stdlib/utils/define-read-only-property/dist'),n={};q(n,"Function",c());q(n,"function2string",v());module.exports=n; -/** @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 398b6fe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../ctor/lib/main.js", "../ctor/lib/index.js", "../to-string/lib/main.js", "../to-string/lib/index.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils/define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nsetReadOnly( ns, 'Function', require( './../ctor' ) );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nsetReadOnly( ns, 'function2string', require( './../to-string' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAM,SAKVD,EAAO,QAAUC,IC3CjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAU,SAAS,UAAU,SAkCjC,SAASC,EAAiBC,EAAM,CAC/B,OAAOF,EAAQ,KAAME,CAAI,CAC1B,CAKAH,EAAO,QAAUE,IChEjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICjBjB,IAAIC,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,WAAY,GAAuB,EASpDD,EAAaC,EAAI,kBAAmB,GAA4B,EAKhE,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "Fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "require_main", "__commonJSMin", "exports", "module", "fcn2str", "function2string", "fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "setReadOnly", "ns"] -} diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ee241a3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 7695a97..a3de6c5 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..f6f1625 --- /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 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From f58607ab6df6b5519f4a25be0c594254d4a3b435 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 8 Nov 2023 03:39:32 +0000 Subject: [PATCH 083/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1dfbac2..20df569 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 155b6b3888863507b1447d2855a633c5f7a1cf0b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 8 Nov 2023 04:00:57 +0000 Subject: [PATCH 084/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6273 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ee241a3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f6f1625..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c38d82f761941ce2bbb9cab8e944e70629de50e7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 8 Nov 2023 04:04:02 +0000 Subject: [PATCH 085/181] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - dist/index.d.ts | 3 - dist/index.js | 11 - dist/index.js.map | 7 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 58 files changed, 6205 insertions(+), 4900 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 49a98a5..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/function) 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 5421fc6..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: '39 3 * * 5' - - # 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 + + ```
@@ -123,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 15e948f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ns from '../docs/types/index'; -export = ns; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d3ecab..0000000 --- a/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=t(function(y,i){ -var x=Function;i.exports=x -});var c=t(function(d,u){ -var f=s();u.exports=f -});var a=t(function(O,o){ -var F=Function.prototype.toString;function g(e){return F.call(e)}o.exports=g -});var v=t(function(R,p){ -var l=a();p.exports=l -});var q=require('@stdlib/utils/define-read-only-property/dist'),n={};q(n,"Function",c());q(n,"function2string",v());module.exports=n; -/** @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 398b6fe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../ctor/lib/main.js", "../ctor/lib/index.js", "../to-string/lib/main.js", "../to-string/lib/index.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils/define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nsetReadOnly( ns, 'Function', require( './../ctor' ) );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nsetReadOnly( ns, 'function2string', require( './../to-string' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAM,SAKVD,EAAO,QAAUC,IC3CjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAU,SAAS,UAAU,SAkCjC,SAASC,EAAiBC,EAAM,CAC/B,OAAOF,EAAQ,KAAME,CAAI,CAC1B,CAKAH,EAAO,QAAUE,IChEjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICjBjB,IAAIC,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,WAAY,GAAuB,EASpDD,EAAaC,EAAI,kBAAmB,GAA4B,EAKhE,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "Fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "require_main", "__commonJSMin", "exports", "module", "fcn2str", "function2string", "fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "setReadOnly", "ns"] -} diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ee241a3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 20df569..82f5a0b 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..1b0c3a1 --- /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 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From f9193b7063e1425e786f1db91a9c69f03aed9668 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 8 Nov 2023 04:16:55 +0000 Subject: [PATCH 086/181] Update README.md for ESM bundle v0.1.0 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4b33c15..90950e3 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import ns from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@esm/index.mjs'; +import ns from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@v0.1.0-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { Function, function2string } from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@esm/index.mjs'; +import { Function, function2string } from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@v0.1.0-esm/index.mjs'; ``` #### ns @@ -92,7 +92,7 @@ The namespace contains the following: - - - - From 01b7902e49c6805c3ae409af94b000a721e5d22b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 8 Nov 2023 05:02:08 +0000 Subject: [PATCH 090/181] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- branches.md | 53 - ctor/README.md | 232 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - dist/index.d.ts | 3 - dist/index.js | 11 - dist/index.js.map | 7 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 58 files changed, 6205 insertions(+), 4900 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 49a98a5..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/function) 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 5421fc6..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: '39 3 * * 5' - - # 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 + + ```
@@ -123,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 8a404f6..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,232 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.apply( null, [ 1, 2 ] ); -// returns 3 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} - -var v = add.call( null, 1, 2 ); -// returns 3 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 15e948f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ns from '../docs/types/index'; -export = ns; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d3ecab..0000000 --- a/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=t(function(y,i){ -var x=Function;i.exports=x -});var c=t(function(d,u){ -var f=s();u.exports=f -});var a=t(function(O,o){ -var F=Function.prototype.toString;function g(e){return F.call(e)}o.exports=g -});var v=t(function(R,p){ -var l=a();p.exports=l -});var q=require('@stdlib/utils/define-read-only-property/dist'),n={};q(n,"Function",c());q(n,"function2string",v());module.exports=n; -/** @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 398b6fe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../ctor/lib/main.js", "../ctor/lib/index.js", "../to-string/lib/main.js", "../to-string/lib/index.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils/define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nsetReadOnly( ns, 'Function', require( './../ctor' ) );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nsetReadOnly( ns, 'function2string', require( './../to-string' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAM,SAKVD,EAAO,QAAUC,IC3CjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAU,SAAS,UAAU,SAkCjC,SAASC,EAAiBC,EAAM,CAC/B,OAAOF,EAAQ,KAAME,CAAI,CAC1B,CAKAH,EAAO,QAAUE,IChEjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICjBjB,IAAIC,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,WAAY,GAAuB,EASpDD,EAAaC,EAAI,kBAAmB,GAA4B,EAKhE,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "Fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "require_main", "__commonJSMin", "exports", "module", "fcn2str", "function2string", "fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "setReadOnly", "ns"] -} diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ee241a3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index eadee6e..db05d8e 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..fd2ada2 --- /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 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From fa287dfb6734f2f7ba388f1bcdb2a2859d2bcfba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 8 Nov 2023 05:13:25 +0000 Subject: [PATCH 091/181] Update README.md for ESM bundle v0.1.1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a9d2e33..b121b33 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import ns from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@esm/index.mjs'; +import ns from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@v0.1.1-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { Function, function2string } from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@esm/index.mjs'; +import { Function, function2string } from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@v0.1.1-esm/index.mjs'; ``` #### ns @@ -92,7 +92,7 @@ The namespace contains the following: - - - - From 1f2eb876f428eecb156c60eabe788dfc5fdc300a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 05:21:30 +0000 Subject: [PATCH 095/181] 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 | 207 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- branches.md | 53 - ctor/README.md | 245 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - dist/index.d.ts | 3 - dist/index.js | 11 - dist/index.js.map | 7 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 40 - to-string/README.md | 143 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 58 files changed, 6205 insertions(+), 4865 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 49a98a5..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/function) 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 5421fc6..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: '39 3 * * 5' - - # 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 + + ```
@@ -123,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 15e948f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ns from '../docs/types/index'; -export = ns; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d3ecab..0000000 --- a/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=t(function(y,i){ -var x=Function;i.exports=x -});var c=t(function(d,u){ -var f=s();u.exports=f -});var a=t(function(O,o){ -var F=Function.prototype.toString;function g(e){return F.call(e)}o.exports=g -});var v=t(function(R,p){ -var l=a();p.exports=l -});var q=require('@stdlib/utils/define-read-only-property/dist'),n={};q(n,"Function",c());q(n,"function2string",v());module.exports=n; -/** @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 398b6fe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../ctor/lib/main.js", "../ctor/lib/index.js", "../to-string/lib/main.js", "../to-string/lib/index.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils/define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nsetReadOnly( ns, 'Function', require( './../ctor' ) );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nsetReadOnly( ns, 'function2string', require( './../to-string' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAM,SAKVD,EAAO,QAAUC,IC3CjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAU,SAAS,UAAU,SAkCjC,SAASC,EAAiBC,EAAM,CAC/B,OAAOF,EAAQ,KAAME,CAAI,CAC1B,CAKAH,EAAO,QAAUE,IChEjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICjBjB,IAAIC,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,WAAY,GAAuB,EASpDD,EAAaC,EAAI,kBAAmB,GAA4B,EAKhE,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "Fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "require_main", "__commonJSMin", "exports", "module", "fcn2str", "function2string", "fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "setReadOnly", "ns"] -} diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ee241a3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index eadee6e..db05d8e 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..5173054 --- /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 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index a99aa4d..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From ca60dda2ffc313550434fb7956172eebe3bb9766 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 12:03:40 +0000 Subject: [PATCH 096/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 41007b3..eadee6e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 195b6b08a8790905c6f9da5d3e80c5ab3c52b55c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 15:48:06 +0000 Subject: [PATCH 097/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6273 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ee241a3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5173054..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 81e07eb68812e59a7aef37ed6aba4db6dd018be1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 15:52:07 +0000 Subject: [PATCH 098/181] 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 | 207 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- branches.md | 53 - ctor/README.md | 245 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 30 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - dist/index.d.ts | 3 - dist/index.js | 11 - dist/index.js.map | 7 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 58 files changed, 6205 insertions(+), 4875 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 49a98a5..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/function) 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 5421fc6..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: '39 3 * * 5' - - # 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 + + ```
@@ -123,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 1ae1e31..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,30 +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. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 15e948f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ns from '../docs/types/index'; -export = ns; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d3ecab..0000000 --- a/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=t(function(y,i){ -var x=Function;i.exports=x -});var c=t(function(d,u){ -var f=s();u.exports=f -});var a=t(function(O,o){ -var F=Function.prototype.toString;function g(e){return F.call(e)}o.exports=g -});var v=t(function(R,p){ -var l=a();p.exports=l -});var q=require('@stdlib/utils/define-read-only-property/dist'),n={};q(n,"Function",c());q(n,"function2string",v());module.exports=n; -/** @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 398b6fe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../ctor/lib/main.js", "../ctor/lib/index.js", "../to-string/lib/main.js", "../to-string/lib/index.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils/define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nsetReadOnly( ns, 'Function', require( './../ctor' ) );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nsetReadOnly( ns, 'function2string', require( './../to-string' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAM,SAKVD,EAAO,QAAUC,IC3CjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAU,SAAS,UAAU,SAkCjC,SAASC,EAAiBC,EAAM,CAC/B,OAAOF,EAAQ,KAAME,CAAI,CAC1B,CAKAH,EAAO,QAAUE,IChEjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICjBjB,IAAIC,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,WAAY,GAAuB,EASpDD,EAAaC,EAAI,kBAAmB,GAA4B,EAKhE,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "Fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "require_main", "__commonJSMin", "exports", "module", "fcn2str", "function2string", "fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "setReadOnly", "ns"] -} diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index ed1e2f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* tslint:disable:no-unused-expression */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ee241a3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index eadee6e..db05d8e 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..5229ee5 --- /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 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 4dba7a03addafc857f72dbac64efe451342364ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 21:53:36 +0000 Subject: [PATCH 099/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 41007b3..eadee6e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f4a5bfac0b2cb197be1ad2917dc000f1bfc621fa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 23:14:56 +0000 Subject: [PATCH 100/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6273 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ee241a3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5229ee5..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 54fbc797c12cb1167f8ddd350669aec68a8c9fe5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 23:17:17 +0000 Subject: [PATCH 101/181] 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 | 207 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- branches.md | 53 - ctor/README.md | 245 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - dist/index.d.ts | 3 - dist/index.js | 11 - dist/index.js.map | 7 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 58 files changed, 6205 insertions(+), 4874 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 49a98a5..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/function) 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 5421fc6..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: '39 3 * * 5' - - # 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 + + ```
@@ -123,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 15e948f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ns from '../docs/types/index'; -export = ns; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d3ecab..0000000 --- a/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=t(function(y,i){ -var x=Function;i.exports=x -});var c=t(function(d,u){ -var f=s();u.exports=f -});var a=t(function(O,o){ -var F=Function.prototype.toString;function g(e){return F.call(e)}o.exports=g -});var v=t(function(R,p){ -var l=a();p.exports=l -});var q=require('@stdlib/utils/define-read-only-property/dist'),n={};q(n,"Function",c());q(n,"function2string",v());module.exports=n; -/** @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 398b6fe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../ctor/lib/main.js", "../ctor/lib/index.js", "../to-string/lib/main.js", "../to-string/lib/index.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils/define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nsetReadOnly( ns, 'Function', require( './../ctor' ) );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nsetReadOnly( ns, 'function2string', require( './../to-string' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAM,SAKVD,EAAO,QAAUC,IC3CjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAU,SAAS,UAAU,SAkCjC,SAASC,EAAiBC,EAAM,CAC/B,OAAOF,EAAQ,KAAME,CAAI,CAC1B,CAKAH,EAAO,QAAUE,IChEjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICjBjB,IAAIC,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,WAAY,GAAuB,EASpDD,EAAaC,EAAI,kBAAmB,GAA4B,EAKhE,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "Fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "require_main", "__commonJSMin", "exports", "module", "fcn2str", "function2string", "fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "setReadOnly", "ns"] -} diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ee241a3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index eadee6e..db05d8e 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..108ca63 --- /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 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 3fae27b50e8018b319e37fe0a48dad454dacf5a4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 01:03:34 +0000 Subject: [PATCH 102/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 41007b3..eadee6e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 69fe09572b93cf904b0208f3537d0f4947374385 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 03:24:36 +0000 Subject: [PATCH 103/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6273 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ee241a3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 108ca63..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 54ae8b0dbff86f7e9eb43de445b1d65785e60d5b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 03:27:08 +0000 Subject: [PATCH 104/181] 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 | 207 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- branches.md | 53 - ctor/README.md | 245 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - dist/index.d.ts | 3 - dist/index.js | 11 - dist/index.js.map | 7 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 59 files changed, 6205 insertions(+), 4870 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 5fe1260..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T00:45:42.129Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 49a98a5..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/function) 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 5421fc6..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: '39 3 * * 5' - - # 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 + + ```
@@ -123,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 15e948f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ns from '../docs/types/index'; -export = ns; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d3ecab..0000000 --- a/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=t(function(y,i){ -var x=Function;i.exports=x -});var c=t(function(d,u){ -var f=s();u.exports=f -});var a=t(function(O,o){ -var F=Function.prototype.toString;function g(e){return F.call(e)}o.exports=g -});var v=t(function(R,p){ -var l=a();p.exports=l -});var q=require('@stdlib/utils/define-read-only-property/dist'),n={};q(n,"Function",c());q(n,"function2string",v());module.exports=n; -/** @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 398b6fe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../ctor/lib/main.js", "../ctor/lib/index.js", "../to-string/lib/main.js", "../to-string/lib/index.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils/define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nsetReadOnly( ns, 'Function', require( './../ctor' ) );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nsetReadOnly( ns, 'function2string', require( './../to-string' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAM,SAKVD,EAAO,QAAUC,IC3CjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAU,SAAS,UAAU,SAkCjC,SAASC,EAAiBC,EAAM,CAC/B,OAAOF,EAAQ,KAAME,CAAI,CAC1B,CAKAH,EAAO,QAAUE,IChEjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICjBjB,IAAIC,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,WAAY,GAAuB,EASpDD,EAAaC,EAAI,kBAAmB,GAA4B,EAKhE,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "Fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "require_main", "__commonJSMin", "exports", "module", "fcn2str", "function2string", "fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "setReadOnly", "ns"] -} diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ee241a3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index eadee6e..db05d8e 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..f06d529 --- /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 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From d67bdfabc9399a1c6baba439a30c7b10f44326dc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 19 Dec 2023 02:37:27 +0000 Subject: [PATCH 105/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 41007b3..eadee6e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 87424c91b4a2c2c2966d6f4ff76f218449f9929e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 19 Dec 2023 02:40:43 +0000 Subject: [PATCH 106/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6273 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ee241a3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f06d529..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 36349a1363f72611e213432a67a41cd22f87e327 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 19 Dec 2023 02:43:37 +0000 Subject: [PATCH 107/181] 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 | 207 - .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 - branches.md | 53 - ctor/README.md | 245 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - dist/index.d.ts | 3 - dist/index.js | 11 - dist/index.js.map | 7 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 40 - to-string/README.md | 155 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 59 files changed, 6205 insertions(+), 4877 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 49a98a5..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/function) 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 ed0b24e..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: '39 3 * * 5' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -123,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 15e948f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ns from '../docs/types/index'; -export = ns; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d3ecab..0000000 --- a/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=t(function(y,i){ -var x=Function;i.exports=x -});var c=t(function(d,u){ -var f=s();u.exports=f -});var a=t(function(O,o){ -var F=Function.prototype.toString;function g(e){return F.call(e)}o.exports=g -});var v=t(function(R,p){ -var l=a();p.exports=l -});var q=require('@stdlib/utils/define-read-only-property/dist'),n={};q(n,"Function",c());q(n,"function2string",v());module.exports=n; -/** @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 398b6fe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../ctor/lib/main.js", "../ctor/lib/index.js", "../to-string/lib/main.js", "../to-string/lib/index.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils/define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nsetReadOnly( ns, 'Function', require( './../ctor' ) );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nsetReadOnly( ns, 'function2string', require( './../to-string' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAM,SAKVD,EAAO,QAAUC,IC3CjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAU,SAAS,UAAU,SAkCjC,SAASC,EAAiBC,EAAM,CAC/B,OAAOF,EAAQ,KAAME,CAAI,CAC1B,CAKAH,EAAO,QAAUE,IChEjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICjBjB,IAAIC,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,WAAY,GAAuB,EASpDD,EAAaC,EAAI,kBAAmB,GAA4B,EAKhE,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "Fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "require_main", "__commonJSMin", "exports", "module", "fcn2str", "function2string", "fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "setReadOnly", "ns"] -} diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ee241a3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index eadee6e..db05d8e 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..f621a72 --- /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 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 59f5330..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,155 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 2dab80bdccab037fedbc70f135f74975bba227e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 00:58:36 +0000 Subject: [PATCH 108/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 41007b3..eadee6e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From cc13a33b2d623be27d0ad27ba15f0b88d37dbb06 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 02:41:46 +0000 Subject: [PATCH 109/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6273 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ee241a3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f621a72..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8e8ef16d70354a93a2dec75e52b3408beb1bf413 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 02:44:39 +0000 Subject: [PATCH 110/181] 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 | 207 - .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 - branches.md | 53 - ctor/README.md | 245 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - dist/index.d.ts | 3 - dist/index.js | 11 - dist/index.js.map | 7 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 40 - to-string/README.md | 155 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 60 files changed, 6205 insertions(+), 4878 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 f7e52a7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T00:44:29.952Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 49a98a5..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/function) 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 26f72b5..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: '39 3 * * 5' - - # 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 + + ```
@@ -123,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e38c6f..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[esm-url]: https://github.com/stdlib-js/function/tree/esm \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 15e948f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ns from '../docs/types/index'; -export = ns; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d3ecab..0000000 --- a/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=t(function(y,i){ -var x=Function;i.exports=x -});var c=t(function(d,u){ -var f=s();u.exports=f -});var a=t(function(O,o){ -var F=Function.prototype.toString;function g(e){return F.call(e)}o.exports=g -});var v=t(function(R,p){ -var l=a();p.exports=l -});var q=require('@stdlib/utils/define-read-only-property/dist'),n={};q(n,"Function",c());q(n,"function2string",v());module.exports=n; -/** @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 398b6fe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../ctor/lib/main.js", "../ctor/lib/index.js", "../to-string/lib/main.js", "../to-string/lib/index.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils/define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nsetReadOnly( ns, 'Function', require( './../ctor' ) );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nsetReadOnly( ns, 'function2string', require( './../to-string' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAM,SAKVD,EAAO,QAAUC,IC3CjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAU,SAAS,UAAU,SAkCjC,SAASC,EAAiBC,EAAM,CAC/B,OAAOF,EAAQ,KAAME,CAAI,CAC1B,CAKAH,EAAO,QAAUE,IChEjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICjBjB,IAAIC,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,WAAY,GAAuB,EASpDD,EAAaC,EAAI,kBAAmB,GAA4B,EAKhE,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "Fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "require_main", "__commonJSMin", "exports", "module", "fcn2str", "function2string", "fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "setReadOnly", "ns"] -} diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b9e1770 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index eadee6e..db05d8e 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..7b3ad01 --- /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 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 59f5330..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,155 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 64bbf4f92c2d67c1c2defc88725025a228c60468 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 00:57:35 +0000 Subject: [PATCH 111/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 41007b3..eadee6e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 9f44909315b213052b3473cd15730b9839497d2e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 02:08:52 +0000 Subject: [PATCH 112/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6273 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b9e1770..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7b3ad01..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8ca4c65d278490d7717e49a218e96c5c0ceb94b0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 02:11:44 +0000 Subject: [PATCH 113/181] 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 | 207 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - dist/index.d.ts | 3 - dist/index.js | 11 - dist/index.js.map | 7 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 40 - to-string/README.md | 155 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 60 files changed, 6205 insertions(+), 4883 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 98ae28f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T00:44:17.437Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 49a98a5..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/function) 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 26f72b5..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 15e948f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ns from '../docs/types/index'; -export = ns; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d3ecab..0000000 --- a/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=t(function(y,i){ -var x=Function;i.exports=x -});var c=t(function(d,u){ -var f=s();u.exports=f -});var a=t(function(O,o){ -var F=Function.prototype.toString;function g(e){return F.call(e)}o.exports=g -});var v=t(function(R,p){ -var l=a();p.exports=l -});var q=require('@stdlib/utils/define-read-only-property/dist'),n={};q(n,"Function",c());q(n,"function2string",v());module.exports=n; -/** @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 398b6fe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../ctor/lib/main.js", "../ctor/lib/index.js", "../to-string/lib/main.js", "../to-string/lib/index.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils/define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nsetReadOnly( ns, 'Function', require( './../ctor' ) );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nsetReadOnly( ns, 'function2string', require( './../to-string' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAM,SAKVD,EAAO,QAAUC,IC3CjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAU,SAAS,UAAU,SAkCjC,SAASC,EAAiBC,EAAM,CAC/B,OAAOF,EAAQ,KAAME,CAAI,CAC1B,CAKAH,EAAO,QAAUE,IChEjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICjBjB,IAAIC,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,WAAY,GAAuB,EASpDD,EAAaC,EAAI,kBAAmB,GAA4B,EAKhE,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "Fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "require_main", "__commonJSMin", "exports", "module", "fcn2str", "function2string", "fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "setReadOnly", "ns"] -} diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b9e1770 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index eadee6e..db05d8e 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.1.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..c69926b --- /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 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 59f5330..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,155 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 2da86de6f4ef1029e31f99d104b6d7d4b4ba6d31 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 5 Feb 2024 03:10:27 +0000 Subject: [PATCH 114/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5bcf122..0b9691e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From aae6bb1bab042d7126e096a59bf13fa513ce2e94 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 5 Feb 2024 03:42:35 +0000 Subject: [PATCH 115/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6273 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b9e1770..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c69926b..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1e934a97db6367dbf1824a6d31a0f8ddd3941eaf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 5 Feb 2024 03:45:28 +0000 Subject: [PATCH 116/181] 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 | 207 - .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 | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - dist/index.d.ts | 3 - dist/index.js | 11 - dist/index.js.map | 7 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 40 - to-string/README.md | 155 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 59 files changed, 6205 insertions(+), 4886 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 49a98a5..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/function) 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 84225a3..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 15e948f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ns from '../docs/types/index'; -export = ns; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d3ecab..0000000 --- a/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=t(function(y,i){ -var x=Function;i.exports=x -});var c=t(function(d,u){ -var f=s();u.exports=f -});var a=t(function(O,o){ -var F=Function.prototype.toString;function g(e){return F.call(e)}o.exports=g -});var v=t(function(R,p){ -var l=a();p.exports=l -});var q=require('@stdlib/utils/define-read-only-property/dist'),n={};q(n,"Function",c());q(n,"function2string",v());module.exports=n; -/** @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 398b6fe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../ctor/lib/main.js", "../ctor/lib/index.js", "../to-string/lib/main.js", "../to-string/lib/index.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils/define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nsetReadOnly( ns, 'Function', require( './../ctor' ) );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nsetReadOnly( ns, 'function2string', require( './../to-string' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAM,SAKVD,EAAO,QAAUC,IC3CjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAU,SAAS,UAAU,SAkCjC,SAASC,EAAiBC,EAAM,CAC/B,OAAOF,EAAQ,KAAME,CAAI,CAC1B,CAKAH,EAAO,QAAUE,IChEjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICjBjB,IAAIC,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,WAAY,GAAuB,EASpDD,EAAaC,EAAI,kBAAmB,GAA4B,EAKhE,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "Fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "require_main", "__commonJSMin", "exports", "module", "fcn2str", "function2string", "fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "setReadOnly", "ns"] -} diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b9e1770 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 0b9691e..6d507e8 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.2.0", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..feb1497 --- /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 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 59f5330..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,155 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 9d96e6da87e4b6dadfb0d7d516da47687f784640 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 5 Feb 2024 03:59:49 +0000 Subject: [PATCH 117/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ac23b2b..43b26b4 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 265a1ba825a73f74c05fceb77b636a1738bf2479 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 5 Feb 2024 04:52:43 +0000 Subject: [PATCH 118/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6273 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b9e1770..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index feb1497..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a431463b868a20e2a764c58cd97cc7d5a031c324 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 5 Feb 2024 04:55:45 +0000 Subject: [PATCH 119/181] 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 | 207 - .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 | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - dist/index.d.ts | 3 - dist/index.js | 11 - dist/index.js.map | 7 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 40 - to-string/README.md | 155 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 59 files changed, 6205 insertions(+), 4886 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 49a98a5..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/function) 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 84225a3..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 15e948f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ns from '../docs/types/index'; -export = ns; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d3ecab..0000000 --- a/dist/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=t(function(y,i){ -var x=Function;i.exports=x -});var c=t(function(d,u){ -var f=s();u.exports=f -});var a=t(function(O,o){ -var F=Function.prototype.toString;function g(e){return F.call(e)}o.exports=g -});var v=t(function(R,p){ -var l=a();p.exports=l -});var q=require('@stdlib/utils/define-read-only-property/dist'),n={};q(n,"Function",c());q(n,"function2string",v());module.exports=n; -/** @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 398b6fe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../ctor/lib/main.js", "../ctor/lib/index.js", "../to-string/lib/main.js", "../to-string/lib/index.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = Fcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Function constructor.\n*\n* @module @stdlib/function/ctor\n*\n* @example\n* var Function = require( '@stdlib/function/ctor' );\n*\n* var add = new Function( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nmodule.exports = function2string;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a string representing the source code of a provided function.\n*\n* @module @stdlib/function/to-string\n*\n* @example\n* var function2string = require( '@stdlib/function/to-string' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils/define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nsetReadOnly( ns, 'Function', require( './../ctor' ) );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nsetReadOnly( ns, 'function2string', require( './../to-string' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAM,SAKVD,EAAO,QAAUC,IC3CjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICzCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAU,SAAS,UAAU,SAkCjC,SAASC,EAAiBC,EAAM,CAC/B,OAAOF,EAAQ,KAAME,CAAI,CAC1B,CAKAH,EAAO,QAAUE,IChEjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,IAAIC,EAAO,IAKXD,EAAO,QAAUC,ICjBjB,IAAIC,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,WAAY,GAAuB,EASpDD,EAAaC,EAAI,kBAAmB,GAA4B,EAKhE,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "Fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "require_main", "__commonJSMin", "exports", "module", "fcn2str", "function2string", "fcn", "require_lib", "__commonJSMin", "exports", "module", "main", "setReadOnly", "ns"] -} diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b9e1770 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 43b26b4..21fa083 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.2.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..8d60dac --- /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 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 59f5330..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,155 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 469e59a32e2a28575d8a02bc8c57ef2c8ce794fa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 5 Feb 2024 04:56:02 +0000 Subject: [PATCH 120/181] Update README.md for ESM bundle v0.2.1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index afdb26f..a24a882 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import ns from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@esm/index.mjs'; +import ns from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@v0.2.1-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { Function, function2string } from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@esm/index.mjs'; +import { Function, function2string } from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@v0.2.1-esm/index.mjs'; ``` #### ns @@ -92,7 +92,7 @@ The namespace contains the following: - - - - From fafb11969adae5c6d21b9dd61a2be557d2dc474c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 5 Feb 2024 05:37:55 +0000 Subject: [PATCH 124/181] 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 | 207 - .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 | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 155 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 55 files changed, 6205 insertions(+), 4832 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 49a98a5..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/function) 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 84225a3..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b9e1770 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 43b26b4..21fa083 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.2.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..b66dafb --- /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 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 59f5330..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,155 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From fd18a29d258bde0815a966fcd59175ad421d4453 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 00:53:50 +0000 Subject: [PATCH 125/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ac23b2b..dbf9b88 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 42d1849c4809d4fbb3648546e400fa519255e4f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 01:26:48 +0000 Subject: [PATCH 126/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6273 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b9e1770..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.1.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b66dafb..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From dcae4f1c3ac238cd535a85d93832cd5a06621974 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 01:29:30 +0000 Subject: [PATCH 127/181] 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 | 207 - .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 | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 155 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 56 files changed, 4870 insertions(+), 4834 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 d9d9f9c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T00:46:23.177Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..345b9f1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index dbf9b88..21fa083 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.2.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..c17d00d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 59f5330..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,155 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From f49214569e02c9b038128659919ae9c405365feb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Mar 2024 04:50:12 +0000 Subject: [PATCH 128/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ac23b2b..dbf9b88 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 7c20a73e3453921c21c479c1ec099a2840294791 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Mar 2024 04:50:35 +0000 Subject: [PATCH 129/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4938 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 345b9f1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c17d00d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From eb2c64c84a58eb17bf5799f1068f73df25998547 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Mar 2024 04:53:18 +0000 Subject: [PATCH 130/181] 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 | 207 - .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 | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 55 files changed, 4870 insertions(+), 4831 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..345b9f1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index dbf9b88..21fa083 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.2.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..c17d00d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From bb8424c2299a88ab16b5aacfe17967d615909b76 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 00:50:06 +0000 Subject: [PATCH 131/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ac23b2b..dbf9b88 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1f60196eecedfda1836c3deff9c2ea80e84e9344 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 01:29:39 +0000 Subject: [PATCH 132/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4938 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 345b9f1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c17d00d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a5097343d0caaec54b07092a737a3bf0dcfc4848 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 01:32:39 +0000 Subject: [PATCH 133/181] 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 | 207 - .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 | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 56 files changed, 4870 insertions(+), 4835 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 f7d868b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T00:42:25.047Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..345b9f1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index dbf9b88..21fa083 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.2.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..c17d00d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 0ee0f6bb12f4be520ca3e370e93a6fb76287f962 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 00:49:16 +0000 Subject: [PATCH 134/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ac23b2b..dbf9b88 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f37d5ba47db036db7dc1f21f39208bc7ae0fd3a5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 01:21:00 +0000 Subject: [PATCH 135/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4938 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 345b9f1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c17d00d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e14d23799fd48240f2145a9c31bb36f322555a2f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 01:24:19 +0000 Subject: [PATCH 136/181] 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 | 206 - .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 | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 56 files changed, 4870 insertions(+), 4844 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 377e092..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-05-01T00:41:27.007Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..345b9f1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index dbf9b88..21fa083 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.2.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..c17d00d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 71089b1c8eb7da1a428e3a95391ba2418ff2f3b8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 00:53:48 +0000 Subject: [PATCH 137/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ac23b2b..dbf9b88 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From d007fbc090122135e64acec066db04905883ec86 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 01:24:39 +0000 Subject: [PATCH 138/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4938 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 345b9f1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c17d00d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b97cf1e65446368345f2124e863e249bf9834cce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 01:27:51 +0000 Subject: [PATCH 139/181] 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 | 206 - .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 | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 56 files changed, 4870 insertions(+), 4844 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 11f6fd7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-06-01T00:46:25.789Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..345b9f1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index dbf9b88..21fa083 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.2.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..c17d00d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From eb4e9fc7eaa3e0d48e7d1169034544f792526580 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 00:55:11 +0000 Subject: [PATCH 140/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ac23b2b..dbf9b88 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 6a5d8affe5d2d21f5b9cf3a0e2ea70a887950dc1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 01:29:11 +0000 Subject: [PATCH 141/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4938 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 345b9f1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c17d00d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3332e8eb3bc26b9a004406f45ed0b564efc50615 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 01:32:12 +0000 Subject: [PATCH 142/181] 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 | 210 - .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 | 46 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 56 files changed, 4870 insertions(+), 4889 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 087c7e5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-07-01T00:48:27.919Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..345b9f1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index dbf9b88..21fa083 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.2.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..c17d00d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 4b46edc88c4055adf8047dae9438b3e6ec58f6d2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 00:55:45 +0000 Subject: [PATCH 143/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ac23b2b..2f9321a 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 8261841e338a11d7b61ed28dfd28141bb01a4c4d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 01:24:24 +0000 Subject: [PATCH 144/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4938 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 345b9f1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.1-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c17d00d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fd5f2d5a5b4f556888c2b2fd4700f13826cdb755 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 01:27:26 +0000 Subject: [PATCH 145/181] 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 | 210 - .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 | 156 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 56 files changed, 4870 insertions(+), 5001 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 696b5f0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T00:49:08.326Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..72d3708 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 2f9321a..21fa083 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.2.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..5dd0a1d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From fe313fa1a19df7a1e76da96eadde2fdfabfab07d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 18 Aug 2024 22:12:11 +0000 Subject: [PATCH 146/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e467a12..dceb673 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From cd9196e4d2c61365b3eaebd2b67ce267c47474ea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 18 Aug 2024 22:53:35 +0000 Subject: [PATCH 147/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4938 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 72d3708..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5dd0a1d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 55331aa45bbac9c4b0bd0b7d530064cb5ed6585f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 18 Aug 2024 22:56:37 +0000 Subject: [PATCH 148/181] 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 | 210 - .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 | 281 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 55 files changed, 4870 insertions(+), 5125 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..72d3708 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index dceb673..a2da5cf 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.3.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..5dd0a1d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 0bee50e2cd87c2c3eabf45aa64906a85cead968c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 18 Aug 2024 23:01:07 +0000 Subject: [PATCH 149/181] Update README.md for ESM bundle v0.3.1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 37b8a5f..0680472 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import ns from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@esm/index.mjs'; +import ns from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@v0.3.1-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { Function, function2string } from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@esm/index.mjs'; +import { Function, function2string } from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@v0.3.1-esm/index.mjs'; ``` #### ns @@ -92,7 +92,7 @@ The namespace contains the following: - - - - From dad8922bad2a68e01dc58134729ac4c94bfd5f3f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 01:36:35 +0000 Subject: [PATCH 153/181] 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 | 210 - .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 | 291 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 56 files changed, 4870 insertions(+), 5136 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 b1bd4d6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T00:55:29.497Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..72d3708 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index dceb673..a2da5cf 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.3.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..5dd0a1d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 57c22df7802feaee5e7fe44f5f2209aa0c26e9a1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 01:01:58 +0000 Subject: [PATCH 154/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e467a12..dceb673 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2ba6ccd0aaa1b377d6db2b0a273f95c0a3a8c707 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 01:23:58 +0000 Subject: [PATCH 155/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4938 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 72d3708..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5dd0a1d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 92a9c43a516551aa22a63935e87d3b40603139f3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 01:27:25 +0000 Subject: [PATCH 156/181] 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 | 210 - .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 | 291 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 56 files changed, 4870 insertions(+), 5136 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 5f5e32e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T00:55:18.146Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..72d3708 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index dceb673..a2da5cf 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.3.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..5dd0a1d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 27cd8e962615c154a1c35438e7cc36db8057c34e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 01:02:26 +0000 Subject: [PATCH 157/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e467a12..dceb673 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 433ddef8637d8fb8e30b7f9fa1f6fa6e50399aed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 01:27:56 +0000 Subject: [PATCH 158/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4938 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 72d3708..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5dd0a1d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9ab3e900997f767edde51ab8e93523d3e1d46efc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 01:31:14 +0000 Subject: [PATCH 159/181] 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 | 210 - .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 | 291 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 56 files changed, 4870 insertions(+), 5136 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 e7d318c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T00:56:29.497Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..72d3708 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index dceb673..a2da5cf 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.3.1", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..5dd0a1d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 10b4e4e2ee8ae71579185ffdde361183bc30acdb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 5 Nov 2024 19:48:06 +0000 Subject: [PATCH 160/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1e90aa1..58a182d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/bench": "github:stdlib-js/bench#main", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From d9d4f7d40801bafc3e194ee6f2df59cee29ba005 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 5 Nov 2024 20:16:56 +0000 Subject: [PATCH 161/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4938 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 72d3708..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5dd0a1d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f51e2a753754420cac9b0bade149d510c6b98701 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 5 Nov 2024 20:20:13 +0000 Subject: [PATCH 162/181] 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 | 210 - .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 | 291 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 55 files changed, 4870 insertions(+), 5135 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..72d3708 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 58a182d..26cb0c9 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.3.2", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..5dd0a1d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From b5df53a5f4bc9446d8c8ba199a1fc56098747e87 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 5 Nov 2024 20:28:40 +0000 Subject: [PATCH 163/181] Update README.md for ESM bundle v0.3.2 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dbebcf3..80e5171 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import ns from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@esm/index.mjs'; +import ns from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@v0.3.2-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { Function, function2string } from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@esm/index.mjs'; +import { Function, function2string } from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@v0.3.2-esm/index.mjs'; ``` #### ns @@ -92,7 +92,7 @@ The namespace contains the following: - - - - From a1509f5dde36c3c0c4d41eb67d1bdc714feab75f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 5 Nov 2024 21:25:05 +0000 Subject: [PATCH 167/181] 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 | 210 - .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 | 301 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 -- ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 55 files changed, 4870 insertions(+), 5145 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 27daa06..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..72d3708 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index e292702..7e98a44 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.3.3", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..5dd0a1d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 9938488bedfef01196e32ecc0d1c28cfb27d17cb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 5 Nov 2024 21:28:45 +0000 Subject: [PATCH 168/181] Update README.md for ESM bundle v0.3.3 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eb409dc..67e701f 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import ns from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@esm/index.mjs'; +import ns from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@v0.3.3-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { Function, function2string } from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@esm/index.mjs'; +import { Function, function2string } from 'https://cdn.jsdelivr.net/gh/stdlib-js/function@v0.3.3-esm/index.mjs'; ``` #### ns @@ -92,7 +92,7 @@ The namespace contains the following: - - - - From 8173e94f6bc745fabc7b61a30362f970e5ac5615 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 01:44:07 +0000 Subject: [PATCH 172/181] 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 | 210 - .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 | 311 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 58 +- stats.html | 4842 ++++++++++++++++++ test/test.js | 40 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 57 files changed, 4870 insertions(+), 5261 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 247a5d5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T01:02:54.147Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 27daa06..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..72d3708 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index e292702..7e98a44 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.3.3", "description": "Function.", "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": { - "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", @@ -35,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -79,4 +27,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..5dd0a1d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 703080e8a126011c5ee2d6e64c6162f98f7145ed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 26 Feb 2025 11:41:22 +0000 Subject: [PATCH 173/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 83f4587..10b4fca 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert": "github:stdlib-js/assert#main", @@ -80,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 4ffee2d0fa0208b15f8c59d94bfdb0e82f18dea5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 26 Feb 2025 11:41:47 +0000 Subject: [PATCH 174/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4938 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 72d3708..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5dd0a1d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0d5cc70fbbf4101efae13422dd1fb987f2642ba0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 26 Feb 2025 11:45:53 +0000 Subject: [PATCH 175/181] 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 | 210 - .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 | 365 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 60 +- stats.html | 4842 ++++++++++++++++++ test/test.js | 40 - thunk/README.md | 134 - thunk/benchmark/benchmark.js | 72 - thunk/docs/repl.txt | 28 - thunk/docs/types/index.d.ts | 45 - thunk/docs/types/test.ts | 58 - thunk/examples/index.js | 37 - thunk/lib/index.js | 47 - thunk/lib/main.js | 68 - thunk/package.json | 68 - thunk/test/test.js | 163 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 66 files changed, 4870 insertions(+), 6039 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 thunk/README.md delete mode 100644 thunk/benchmark/benchmark.js delete mode 100644 thunk/docs/repl.txt delete mode 100644 thunk/docs/types/index.d.ts delete mode 100644 thunk/docs/types/test.ts delete mode 100644 thunk/examples/index.js delete mode 100644 thunk/lib/index.js delete mode 100644 thunk/lib/main.js delete mode 100644 thunk/package.json delete mode 100644 thunk/test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 bbf590e..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fe3fbfd --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 10b4fca..7e98a44 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.3.3", "description": "Function.", "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": { - "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", @@ -35,38 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert": "github:stdlib-js/assert#main", - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/number": "github:stdlib-js/number#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -81,4 +27,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..5dd0a1d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/thunk/README.md b/thunk/README.md deleted file mode 100644 index 842dd43..0000000 --- a/thunk/README.md +++ /dev/null @@ -1,134 +0,0 @@ - - -# thunk - -> Generate a [thunk][thunk]. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var thunk = require( '@stdlib/function/thunk' ); -``` - -#### thunk( fcn\[, ...args] ) - -Returns a [thunk][thunk] (i.e., an anonymous function having arity `0` and which invokes a provided function with specified arguments). - -```javascript -var add = require( '@stdlib/number/float64/base/add' ); - -var f = thunk( add, 2.0, 3.0 ); -// returns - -var v = f(); -// returns 5 - -// ... - -v = f(); -// returns 5 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var add = require( '@stdlib/number/float64/base/add' ); -var decorateAfter = require( '@stdlib/utils/decorate-after' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var thunk = require( '@stdlib/function/thunk' ); - -function log( v ) { - console.log( v ); -} - -// Create a PRNG for generating uniformly distributed pseudorandom integers: -var randi = discreteUniform( 100, 1000 ); - -// Randomly delay evaluation of various thunks... -var i; -for ( i = 0; i < 10; i++ ) { - setTimeout( decorateAfter( thunk( add, i, i+1 ), 0, log ), randi() ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/thunk/benchmark/benchmark.js b/thunk/benchmark/benchmark.js deleted file mode 100644 index 54a28e7..0000000 --- a/thunk/benchmark/benchmark.js +++ /dev/null @@ -1,72 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var pkg = require( './../package.json' ).name; -var thunk = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = thunk( abs, -0.0 ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::thunk', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = thunk( abs, -0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn(); // NOTE: this may get optimized away as returning the same value for each loop iteration - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( out ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/thunk/docs/repl.txt b/thunk/docs/repl.txt deleted file mode 100644 index 5f5afea..0000000 --- a/thunk/docs/repl.txt +++ /dev/null @@ -1,28 +0,0 @@ - -{{alias}}( fcn[, ...args] ) - Returns a thunk. - - Parameters - ---------- - fcn: Function - Function to convert to a thunk. - - args: ...any (optional) - Function arguments. - - Returns - ------- - out: Function - Thunk. - - Examples - -------- - > var fcn = {{alias}}( {{alias:@stdlib/number/float64/base/add}}, 2, 3 ); - > var v = fcn() - 5 - > v = fcn() - 5 - - See Also - -------- - diff --git a/thunk/docs/types/index.d.ts b/thunk/docs/types/index.d.ts deleted file mode 100644 index d2244b0..0000000 --- a/thunk/docs/types/index.d.ts +++ /dev/null @@ -1,45 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a thunk. -* -* @param fcn - function to convert to a thunk -* @param args - function args -* @returns thunk -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var f = thunk( add, 2, 3 ); -* // returns -* -* // ... -* -* // Evaluate the thunk: -* var v = f(); -* // returns 5 -*/ -declare function thunk, U>( fcn: ( ...args: T ) => U, ...args: T ): () => U; - - -// EXPORTS // - -export = thunk; diff --git a/thunk/docs/types/test.ts b/thunk/docs/types/test.ts deleted file mode 100644 index 357c664..0000000 --- a/thunk/docs/types/test.ts +++ /dev/null @@ -1,58 +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. -*/ - -import thunk = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - thunk<[], number>( (): number => 2 ); // $ExpectType () => number - thunk, number>( ( x: number ): number => x, 2 ); // $ExpectType () => number - thunk<[number, number], number>( ( x: number, y: number ): number => x + y, 2, 3 ); // $ExpectType () => number -} - -// The compiler throws an error if the function is provided a first argument which is not a function... -{ - thunk( true ); // $ExpectError - thunk( false ); // $ExpectError - thunk( 5 ); // $ExpectError - thunk( [] ); // $ExpectError - thunk( {} ); // $ExpectError - thunk( 'abc' ); // $ExpectError - - thunk( true, 2 ); // $ExpectError - thunk( false, 2 ); // $ExpectError - thunk( 5, 2 ); // $ExpectError - thunk( [], 2 ); // $ExpectError - thunk( {}, 2 ); // $ExpectError - thunk( 'abc', 2 ); // $ExpectError - - thunk( true, 2, 3 ); // $ExpectError - thunk( false, 2, 3 ); // $ExpectError - thunk( 5, 2, 3 ); // $ExpectError - thunk( [], 2, 3 ); // $ExpectError - thunk( {}, 2, 3 ); // $ExpectError - thunk( 'abc', 2, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided an incorrect number of arguments... -{ - thunk(); // $ExpectError -} diff --git a/thunk/examples/index.js b/thunk/examples/index.js deleted file mode 100644 index 1097300..0000000 --- a/thunk/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var add = require( '@stdlib/number/float64/base/add' ); -var decorateAfter = require( '@stdlib/utils/decorate-after' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var thunk = require( './../lib' ); - -function log( v ) { - console.log( v ); -} - -// Create a PRNG for generating uniformly distributed pseudorandom integers: -var randi = discreteUniform( 100, 1000 ); - -// Randomly delay evaluation of various thunks... -var i; -for ( i = 0; i < 10; i++ ) { - setTimeout( decorateAfter( thunk( add, i, i+1 ), 0, log ), randi() ); -} diff --git a/thunk/lib/index.js b/thunk/lib/index.js deleted file mode 100644 index 97f7df1..0000000 --- a/thunk/lib/index.js +++ /dev/null @@ -1,47 +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. -*/ - -'use strict'; - -/** -* Generate a thunk. -* -* @module @stdlib/function/thunk -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var thunk = require( '@stdlib/function/thunk' ); -* -* var f = thunk( add, 2, 3 ); -* // returns -* -* // ... -* -* // Evaluate the thunk: -* var v = f(); -* // returns 5 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/thunk/lib/main.js b/thunk/lib/main.js deleted file mode 100644 index 106b46e..0000000 --- a/thunk/lib/main.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert/is-function' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns a thunk. -* -* @param {Function} fcn - function to convert to a thunk -* @param {...*} [args] - function arguments -* @throws {TypeError} first argument must be a function -* @returns {Function} thunk -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var f = thunk( add, 2, 3 ); -* // returns -* -* // ... -* -* // Evaluate the thunk: -* var v = f(); -* // returns 5 -*/ -function thunk( fcn ) { - var args; - var i; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); - } - args = []; - for ( i = 1; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - // NOTE: we return an anonymous function to satisfy the definition of a thunk (i.e., an anonymous function which has no parameters of its own and wraps another function)... - return function () { // eslint-disable-line no-restricted-syntax, func-names - return fcn.apply( null, args ); - }; -} - - -// EXPORTS // - -module.exports = thunk; diff --git a/thunk/package.json b/thunk/package.json deleted file mode 100644 index 924a235..0000000 --- a/thunk/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/function/thunk", - "version": "0.0.0", - "description": "Generate a thunk.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdutils", - "stdutil", - "utilities", - "utils", - "util", - "thunk", - "delay", - "wrap", - "lazy", - "function", - "fun", - "func", - "fcn", - "functional" - ] -} diff --git a/thunk/test/test.js b/thunk/test/test.js deleted file mode 100644 index a6c16fb..0000000 --- a/thunk/test/test.js +++ /dev/null @@ -1,163 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var functionName = require( '@stdlib/utils/function-name' ); -var add = require( '@stdlib/number/float64/base/add' ); -var thunk = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof thunk, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - thunk( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a function (2 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - thunk( value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a function (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - thunk( value, 2, 3 ); - }; - } -}); - -tape( 'the function returns an anonymous function having arity 0', function test( t ) { - var fcn = thunk( add, 2, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns expected value' ); - t.strictEqual( functionName( fcn ), '', 'returns expected value' ); - t.strictEqual( fcn.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a thunk (nullary)', function test( t ) { - var fcn = thunk( constant ); - t.strictEqual( fcn(), 3.14, 'returns expected value' ); - t.strictEqual( fcn(), 3.14, 'returns expected value' ); - t.strictEqual( fcn(), 3.14, 'returns expected value' ); - t.end(); - - function constant() { - return 3.14; - } -}); - -tape( 'the function returns a thunk (unary)', function test( t ) { - var fcn = thunk( scale, 3.0 ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v + 1.0; - } -}); - -tape( 'the function returns a thunk (binary)', function test( t ) { - var fcn = thunk( add, 3.0, 1.0 ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 4545b0e7be09ce621b3689b49ec4de7349154b48 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 00:31:31 +0000 Subject: [PATCH 176/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 83f4587..10b4fca 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert": "github:stdlib-js/assert#main", @@ -80,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 319cbe80b8cb7d0fa1c9aa147bfe8d75acdf6886 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 00:32:19 +0000 Subject: [PATCH 177/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4938 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fe3fbfd..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5dd0a1d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 171d34af3dcb2bb1e581794efbeaf33ce38dbb11 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 00:36:00 +0000 Subject: [PATCH 178/181] 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 | 210 - .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 | 365 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 60 +- stats.html | 4842 ++++++++++++++++++ test/test.js | 40 - thunk/README.md | 134 - thunk/benchmark/benchmark.js | 72 - thunk/docs/repl.txt | 28 - thunk/docs/types/index.d.ts | 45 - thunk/docs/types/test.ts | 58 - thunk/examples/index.js | 37 - thunk/lib/index.js | 47 - thunk/lib/main.js | 68 - thunk/package.json | 68 - thunk/test/test.js | 163 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 67 files changed, 4870 insertions(+), 6040 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 thunk/README.md delete mode 100644 thunk/benchmark/benchmark.js delete mode 100644 thunk/docs/repl.txt delete mode 100644 thunk/docs/types/index.d.ts delete mode 100644 thunk/docs/types/test.ts delete mode 100644 thunk/examples/index.js delete mode 100644 thunk/lib/index.js delete mode 100644 thunk/lib/main.js delete mode 100644 thunk/package.json delete mode 100644 thunk/test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 9f99fa6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-24T00:30:58.528Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bbf590e..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index 63e39ca..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fe3fbfd --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 10b4fca..7e98a44 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.3.3", "description": "Function.", "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": { - "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", @@ -35,38 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert": "github:stdlib-js/assert#main", - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/number": "github:stdlib-js/number#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -81,4 +27,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..5dd0a1d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/thunk/README.md b/thunk/README.md deleted file mode 100644 index 842dd43..0000000 --- a/thunk/README.md +++ /dev/null @@ -1,134 +0,0 @@ - - -# thunk - -> Generate a [thunk][thunk]. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var thunk = require( '@stdlib/function/thunk' ); -``` - -#### thunk( fcn\[, ...args] ) - -Returns a [thunk][thunk] (i.e., an anonymous function having arity `0` and which invokes a provided function with specified arguments). - -```javascript -var add = require( '@stdlib/number/float64/base/add' ); - -var f = thunk( add, 2.0, 3.0 ); -// returns - -var v = f(); -// returns 5 - -// ... - -v = f(); -// returns 5 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var add = require( '@stdlib/number/float64/base/add' ); -var decorateAfter = require( '@stdlib/utils/decorate-after' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var thunk = require( '@stdlib/function/thunk' ); - -function log( v ) { - console.log( v ); -} - -// Create a PRNG for generating uniformly distributed pseudorandom integers: -var randi = discreteUniform( 100, 1000 ); - -// Randomly delay evaluation of various thunks... -var i; -for ( i = 0; i < 10; i++ ) { - setTimeout( decorateAfter( thunk( add, i, i+1 ), 0, log ), randi() ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/thunk/benchmark/benchmark.js b/thunk/benchmark/benchmark.js deleted file mode 100644 index 54a28e7..0000000 --- a/thunk/benchmark/benchmark.js +++ /dev/null @@ -1,72 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var pkg = require( './../package.json' ).name; -var thunk = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = thunk( abs, -0.0 ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::thunk', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = thunk( abs, -0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn(); // NOTE: this may get optimized away as returning the same value for each loop iteration - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( out ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/thunk/docs/repl.txt b/thunk/docs/repl.txt deleted file mode 100644 index 5f5afea..0000000 --- a/thunk/docs/repl.txt +++ /dev/null @@ -1,28 +0,0 @@ - -{{alias}}( fcn[, ...args] ) - Returns a thunk. - - Parameters - ---------- - fcn: Function - Function to convert to a thunk. - - args: ...any (optional) - Function arguments. - - Returns - ------- - out: Function - Thunk. - - Examples - -------- - > var fcn = {{alias}}( {{alias:@stdlib/number/float64/base/add}}, 2, 3 ); - > var v = fcn() - 5 - > v = fcn() - 5 - - See Also - -------- - diff --git a/thunk/docs/types/index.d.ts b/thunk/docs/types/index.d.ts deleted file mode 100644 index d2244b0..0000000 --- a/thunk/docs/types/index.d.ts +++ /dev/null @@ -1,45 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a thunk. -* -* @param fcn - function to convert to a thunk -* @param args - function args -* @returns thunk -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var f = thunk( add, 2, 3 ); -* // returns -* -* // ... -* -* // Evaluate the thunk: -* var v = f(); -* // returns 5 -*/ -declare function thunk, U>( fcn: ( ...args: T ) => U, ...args: T ): () => U; - - -// EXPORTS // - -export = thunk; diff --git a/thunk/docs/types/test.ts b/thunk/docs/types/test.ts deleted file mode 100644 index 357c664..0000000 --- a/thunk/docs/types/test.ts +++ /dev/null @@ -1,58 +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. -*/ - -import thunk = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - thunk<[], number>( (): number => 2 ); // $ExpectType () => number - thunk, number>( ( x: number ): number => x, 2 ); // $ExpectType () => number - thunk<[number, number], number>( ( x: number, y: number ): number => x + y, 2, 3 ); // $ExpectType () => number -} - -// The compiler throws an error if the function is provided a first argument which is not a function... -{ - thunk( true ); // $ExpectError - thunk( false ); // $ExpectError - thunk( 5 ); // $ExpectError - thunk( [] ); // $ExpectError - thunk( {} ); // $ExpectError - thunk( 'abc' ); // $ExpectError - - thunk( true, 2 ); // $ExpectError - thunk( false, 2 ); // $ExpectError - thunk( 5, 2 ); // $ExpectError - thunk( [], 2 ); // $ExpectError - thunk( {}, 2 ); // $ExpectError - thunk( 'abc', 2 ); // $ExpectError - - thunk( true, 2, 3 ); // $ExpectError - thunk( false, 2, 3 ); // $ExpectError - thunk( 5, 2, 3 ); // $ExpectError - thunk( [], 2, 3 ); // $ExpectError - thunk( {}, 2, 3 ); // $ExpectError - thunk( 'abc', 2, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided an incorrect number of arguments... -{ - thunk(); // $ExpectError -} diff --git a/thunk/examples/index.js b/thunk/examples/index.js deleted file mode 100644 index 1097300..0000000 --- a/thunk/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var add = require( '@stdlib/number/float64/base/add' ); -var decorateAfter = require( '@stdlib/utils/decorate-after' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var thunk = require( './../lib' ); - -function log( v ) { - console.log( v ); -} - -// Create a PRNG for generating uniformly distributed pseudorandom integers: -var randi = discreteUniform( 100, 1000 ); - -// Randomly delay evaluation of various thunks... -var i; -for ( i = 0; i < 10; i++ ) { - setTimeout( decorateAfter( thunk( add, i, i+1 ), 0, log ), randi() ); -} diff --git a/thunk/lib/index.js b/thunk/lib/index.js deleted file mode 100644 index 97f7df1..0000000 --- a/thunk/lib/index.js +++ /dev/null @@ -1,47 +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. -*/ - -'use strict'; - -/** -* Generate a thunk. -* -* @module @stdlib/function/thunk -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var thunk = require( '@stdlib/function/thunk' ); -* -* var f = thunk( add, 2, 3 ); -* // returns -* -* // ... -* -* // Evaluate the thunk: -* var v = f(); -* // returns 5 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/thunk/lib/main.js b/thunk/lib/main.js deleted file mode 100644 index 106b46e..0000000 --- a/thunk/lib/main.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert/is-function' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns a thunk. -* -* @param {Function} fcn - function to convert to a thunk -* @param {...*} [args] - function arguments -* @throws {TypeError} first argument must be a function -* @returns {Function} thunk -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var f = thunk( add, 2, 3 ); -* // returns -* -* // ... -* -* // Evaluate the thunk: -* var v = f(); -* // returns 5 -*/ -function thunk( fcn ) { - var args; - var i; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); - } - args = []; - for ( i = 1; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - // NOTE: we return an anonymous function to satisfy the definition of a thunk (i.e., an anonymous function which has no parameters of its own and wraps another function)... - return function () { // eslint-disable-line no-restricted-syntax, func-names - return fcn.apply( null, args ); - }; -} - - -// EXPORTS // - -module.exports = thunk; diff --git a/thunk/package.json b/thunk/package.json deleted file mode 100644 index 924a235..0000000 --- a/thunk/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/function/thunk", - "version": "0.0.0", - "description": "Generate a thunk.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdutils", - "stdutil", - "utilities", - "utils", - "util", - "thunk", - "delay", - "wrap", - "lazy", - "function", - "fun", - "func", - "fcn", - "functional" - ] -} diff --git a/thunk/test/test.js b/thunk/test/test.js deleted file mode 100644 index a6c16fb..0000000 --- a/thunk/test/test.js +++ /dev/null @@ -1,163 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var functionName = require( '@stdlib/utils/function-name' ); -var add = require( '@stdlib/number/float64/base/add' ); -var thunk = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof thunk, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - thunk( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a function (2 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - thunk( value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a function (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - thunk( value, 2, 3 ); - }; - } -}); - -tape( 'the function returns an anonymous function having arity 0', function test( t ) { - var fcn = thunk( add, 2, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns expected value' ); - t.strictEqual( functionName( fcn ), '', 'returns expected value' ); - t.strictEqual( fcn.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a thunk (nullary)', function test( t ) { - var fcn = thunk( constant ); - t.strictEqual( fcn(), 3.14, 'returns expected value' ); - t.strictEqual( fcn(), 3.14, 'returns expected value' ); - t.strictEqual( fcn(), 3.14, 'returns expected value' ); - t.end(); - - function constant() { - return 3.14; - } -}); - -tape( 'the function returns a thunk (unary)', function test( t ) { - var fcn = thunk( scale, 3.0 ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v + 1.0; - } -}); - -tape( 'the function returns a thunk (binary)', function test( t ) { - var fcn = thunk( add, 3.0, 1.0 ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -}); From 403db07d8b59d1c9cda5da0f48bae603b222b19d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 29 Apr 2025 05:51:19 +0000 Subject: [PATCH 179/181] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 83f4587..10b4fca 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main" + "@stdlib/utils": "github:stdlib-js/utils#main", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert": "github:stdlib-js/assert#main", @@ -80,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 998b7ed816bca1552c8cb3f1dad7f0f115c00a12 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 29 Apr 2025 05:51:35 +0000 Subject: [PATCH 180/181] Remove files --- index.d.ts | 91 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4938 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 64e549f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,91 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import Function = require( './../../ctor' ); -import function2string = require( './../../to-string' ); - -/** -* Interface describing the `function` namespace. -*/ -interface Namespace { - /** - * Returns a Function object. - * - * ## Notes - * - * - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - * - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. - * - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). - * - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - * - * @param argNames - parameter names - * @param body - function body - * @returns function - * - * @example - * var add = new ns.Function( 'x', 'y', 'return x + y' ); - * - * var v = add( 1, 2 ); - * // returns 3 - */ - Function: typeof Function; - - /** - * Returns a string representing the source code of a provided function. - * - * ## Notes - * - * - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - * - * ```text - * "function foo() { [native code] }" - * ``` - * - * For intrinsic object methods and functions, `foo` is the initial name of the function. - * - * - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - * - * - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - * - * @param fcn - input function - * @returns string representing function source code - * - * @example - * function add( x, y ) { - * return x + y; - * } - * - * var str = ns.function2string( add ); - * // e.g., returns 'function add( x, y ) {\n return x + y;\n}' - */ - function2string: typeof function2string; -} - -/** -* Function. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fe3fbfd..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c8bd62..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5dd0a1d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ac0150a7794222791ba4b9e6234277b76687950c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 29 Apr 2025 05:55:23 +0000 Subject: [PATCH 181/181] 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 | 210 - .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 | 244 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - branches.md | 56 - ctor/README.md | 245 - ctor/benchmark/benchmark.js | 92 - ctor/docs/repl.txt | 143 - ctor/docs/types/index.d.ts | 43 - ctor/docs/types/test.ts | 29 - ctor/examples/index.js | 29 - ctor/lib/index.js | 42 - ctor/lib/main.js | 44 - ctor/package.json | 58 - ctor/test/test.js | 45 - docs/types/test.ts | 29 - examples/index.js | 24 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 60 - package.json | 60 +- stats.html | 4842 ++++++++++++++++++ test/test.js | 40 - thunk/README.md | 134 - thunk/benchmark/benchmark.js | 72 - thunk/docs/repl.txt | 28 - thunk/docs/types/index.d.ts | 45 - thunk/docs/types/test.ts | 58 - thunk/examples/index.js | 37 - thunk/lib/index.js | 47 - thunk/lib/main.js | 68 - thunk/package.json | 68 - thunk/test/test.js | 163 - to-string/README.md | 153 - to-string/benchmark/benchmark.js | 61 - to-string/docs/repl.txt | 41 - to-string/docs/types/index.d.ts | 54 - to-string/docs/types/test.ts | 43 - to-string/examples/index.js | 42 - to-string/lib/index.js | 44 - to-string/lib/main.js | 65 - to-string/package.json | 61 - to-string/test/test.js | 85 - 66 files changed, 4870 insertions(+), 5918 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 branches.md delete mode 100644 ctor/README.md delete mode 100644 ctor/benchmark/benchmark.js delete mode 100644 ctor/docs/repl.txt delete mode 100644 ctor/docs/types/index.d.ts delete mode 100644 ctor/docs/types/test.ts delete mode 100644 ctor/examples/index.js delete mode 100644 ctor/lib/index.js delete mode 100644 ctor/lib/main.js delete mode 100644 ctor/package.json delete mode 100644 ctor/test/test.js delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 thunk/README.md delete mode 100644 thunk/benchmark/benchmark.js delete mode 100644 thunk/docs/repl.txt delete mode 100644 thunk/docs/types/index.d.ts delete mode 100644 thunk/docs/types/test.ts delete mode 100644 thunk/examples/index.js delete mode 100644 thunk/lib/index.js delete mode 100644 thunk/lib/main.js delete mode 100644 thunk/package.json delete mode 100644 thunk/test/test.js delete mode 100644 to-string/README.md delete mode 100644 to-string/benchmark/benchmark.js delete mode 100644 to-string/docs/repl.txt delete mode 100644 to-string/docs/types/index.d.ts delete mode 100644 to-string/docs/types/test.ts delete mode 100644 to-string/examples/index.js delete mode 100644 to-string/lib/index.js delete mode 100644 to-string/lib/main.js delete mode 100644 to-string/package.json delete mode 100644 to-string/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 bbf590e..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/function) 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 49a98a5..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/function) 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 d8c5cc1..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: '39 3 * * 5' - - # 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 + + ```
@@ -125,7 +122,7 @@ console.log( objectKeys( ns ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/branches.md b/branches.md deleted file mode 100644 index 451b2f4..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/function" -%% click B href "https://github.com/stdlib-js/function/tree/main" -%% click C href "https://github.com/stdlib-js/function/tree/production" -%% click D href "https://github.com/stdlib-js/function/tree/esm" -%% click E href "https://github.com/stdlib-js/function/tree/deno" -%% click F href "https://github.com/stdlib-js/function/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/function -[production-url]: https://github.com/stdlib-js/function/tree/production -[deno-url]: https://github.com/stdlib-js/function/tree/deno -[deno-readme]: https://github.com/stdlib-js/function/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/function/tree/umd -[umd-readme]: https://github.com/stdlib-js/function/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/function/tree/esm -[esm-readme]: https://github.com/stdlib-js/function/blob/esm/README.md \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index abcace7..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# Function - -> [Function][mdn-function] constructor. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Function = require( '@stdlib/function/ctor' ); -``` - -#### Function( \[...argNames,] body ) - -Returns a new [function][mdn-function] object. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); - -var v = greet( 'Jane' ); -// returns 'Hello, Jane!' -``` - -Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). - -* * * - -### Properties - - - -#### Function.prototype.length - -A number representing the number of arguments expected by the function. - -```javascript -var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); -var v = greet.length; -// returns 1 -``` - - - -#### Function.prototype.name - -**Read-only** property representing the name of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var v = greet.name; -// returns 'greet' - -// Functions created with the Function constructor are anonymous: -var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); -v = fcn.name; -// returns 'anonymous' -``` - - - -#### Function.prototype.prototype - -**Read-only** property representing the prototype of the function. - -```javascript -function greet( name ) { - return 'Hello, '+name+'!'; -} -var proto = greet.prototype; -// returns {} -``` - -* * * - -### Methods - - - -#### Function.prototype.apply( thisArg, args ) - -Calls the specified function with the given `this` argument and arguments provided as an array-like object. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.apply( ctx, [ 1, 2 ] ); -// returns 13 -``` - - - -#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Returns a new function which invokes the original function with the given `this` value and arguments. - -```javascript -function add( x, y ) { - return x + y; -} -var add1 = add.bind( null, 1 ); - -var v = add1( 2 ); -// returns 3 -``` - - - -#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) - -Calls the specified function with the given `this` value and arguments. - - - -```javascript -function add( x, y ) { - return this.initial + x + y; -} - -var ctx = { - 'initial': 10 -}; - -var v = add.call( ctx, 1, 2 ); -// returns 13 -``` - - - -#### Function.prototype.toString() - -Returns a string representing the function. - -```javascript -function add( x, y ) { - return x + y; -} -var v = add.toString(); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- In pre-ES2015 environments, only plain identifiers (without defaults) are valid JavaScript parameters. -- Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -- The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -- The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. - -
- - - - - -
- -## Examples - - - -```javascript -var Function = require( '@stdlib/function/ctor' ); - -var add = new Function( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 6a7b56b..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Fcn = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var f; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = new Fcn( 'x', 'y', 'return x + y' ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::evaluation', function benchmark( b ) { - var f; - var v; - var i; - - f = new Fcn( 'x', 'y', 'return x + y' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = f( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::inline', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = add( i, i+1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/ctor/docs/repl.txt b/ctor/docs/repl.txt deleted file mode 100644 index cf580f1..0000000 --- a/ctor/docs/repl.txt +++ /dev/null @@ -1,143 +0,0 @@ - -{{alias}}( [...argNames,] body ) - Returns a Function object. - - Argument names must be strings corresponding to valid JavaScript parameters - (i.e., a plain identifier, or, in environments supporting such parameters, a - rest parameter or destructured parameter, optionally with a default). - - Parameters - ---------- - argNames: ...any (optional) - Parameter names. - - body: string - Function body. - - Returns - ------- - fcn: Function - Function object. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f( 1, 2 ) - 3 - - -{{alias}}.prototype.apply( thisArg, args ) - Calls a function with a given `this` value and arguments provided as an - array (or array-like object). - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: Array - Array of arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.apply( null, [ 1, 2 ] ) - 3 - -{{alias}}.prototype.call( thisArg, ...args ) - Calls a function with a given `this` value and arguments provided - individually. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - out: any - Function return value. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.call( null, 1, 2 ) - 3 - -{{alias}}.prototype.bind( thisArg, ...args ) - Creates a new function which, when called, has its `this` keyword set to the - provided value, with a given sequence of arguments preceding any provided - when the new function is called. - - Parameters - ---------- - thisArg: any - Value to use as `this` when executing the function. - - args: ...any - Arguments to pass to the function. - - Returns - ------- - fcn: Function - Bound function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > var g = f.bind( null, 1 ); - > g( 2 ) - 3 - -{{alias}}.prototype.toString() - Returns a string representation of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.toString() - 'function anonymous( x, y ) { return x + y; }' - -{{alias}}.prototype.length - The number of arguments expected by the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.length - 2 - -{{alias}}.prototype.name - The name of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name - 'anonymous' - - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.name = 'add'; - > f.name - 'add' - -{{alias}}.prototype.prototype - The prototype of the function. - - Examples - -------- - > var f = new {{alias}}( 'x', 'y', 'return x + y' ); - > f.prototype - {} - - See Also - -------- - diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index c936eae..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Returns a Function object. -* -* ## Notes -* -* - Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default). -* - Creating `Function` objects with the `Function` constructor is less efficient than declaring a function via a function expression or a function statement. -* - The `Function` constructor can be invoked without the `new` operator (using `new` and not using `new` both return a new `Function` object). -* - The `Function` constructor creates functions which execute in the **global scope**. Hence, created functions **cannot** access variables local to the scope in which functions were created. -* -* @param argNames - parameter names -* @param body - function body -* @returns function -* -* @example -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -export = Function; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index 3f3f6f6..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Fcn = require( './index' ); - - -// TESTS // - -// The function returns a function object... -{ - new Fcn( 'x', 'y', 'return x + y' ); // $ExpectType Function -} diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 5a1c88b..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var Fcn = require( './../lib' ); - -var add = new Fcn( 'x', 'y', 'return x + y' ); - -var v = add( 1, 2 ); -// returns 3 - -console.log( v ); -// => 3 diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index f3a4573..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -/** -* Function constructor. -* -* @module @stdlib/function/ctor -* -* @example -* var Function = require( '@stdlib/function/ctor' ); -* -* var add = new Function( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index ba6c2f0..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a Function object. -* -* @name Function -* @constructor -* @type {Function} -* @param {...*} [argNames] - parameters names -* @param {string} body - function body -* @returns {Function} function -* -* @example -* var add = new Fcn( 'x', 'y', 'return x + y' ); -* -* var v = add( 1, 2 ); -* // returns 3 -*/ -var Fcn = Function; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = Fcn; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 169e968..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@stdlib/function/ctor", - "version": "0.0.0", - "description": "Function constructor.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "constructor", - "ctor" - ], - "__stdlib__": {} -} diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index b168d9b..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Fcn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Fcn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the main export is the `Function` global', function test( t ) { - t.strictEqual( Fcn, Function, 'returns expected value' ); // eslint-disable-line stdlib/require-globals - t.end(); -}); - -tape( 'the function returns a Function object', function test( t ) { - var add = new Fcn( 'x', 'y', 'return x + y' ); - var v = add( 1, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - t.end(); -}); diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e344b79..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d903e87..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +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. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fe3fbfd --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";var n=Function,i=Function.prototype.toString;function o(t){return i.call(t)}var r={};t(r,"Function",n),t(r,"function2string",o);export{n as Function,r as default,o as function2string}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c8bd62 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../ctor/lib/main.js","../to-string/lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a Function object.\n*\n* @name Function\n* @constructor\n* @type {Function}\n* @param {...*} [argNames] - parameters names\n* @param {string} body - function body\n* @returns {Function} function\n*\n* @example\n* var add = new Fcn( 'x', 'y', 'return x + y' );\n*\n* var v = add( 1, 2 );\n* // returns 3\n*/\nvar Fcn = Function; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Fcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\n// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:\nvar fcn2str = Function.prototype.toString;\n\n\n// MAIN //\n\n/**\n* Returns a string representing the source code of a provided function.\n*\n* ## Notes\n*\n* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a \"native\" function string similar to the following:\n*\n* ```text\n* \"function foo() { [native code] }\"\n* ```\n*\n* For intrinsic object methods and functions, `foo` is the initial name of the function.\n*\n* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name \"anonymous\" and using the provided parameters and function body.\n*\n* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} string representing function source code\n*\n* @example\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var str = function2string( add );\n* // e.g., returns 'function add( x, y ) {\\n return x + y;\\n}'\n*/\nfunction function2string( fcn ) {\n\treturn fcn2str.call( fcn );\n}\n\n\n// EXPORTS //\n\nexport default function2string;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name Function\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/ctor}\n*/\nimport Function from './../ctor';\nsetReadOnly( ns, 'Function', Function );\n\n/**\n* @name function2string\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/function/to-string}\n*/\nimport function2string from './../to-string';\nsetReadOnly( ns, 'function2string', function2string );\n\n\n// EXPORTS //\n\nexport default ns;\n"],"names":["Fcn","Function","fcn2str","prototype","toString","function2string","fcn","call","ns","setReadOnly"],"mappings":";;0GAsCG,IAACA,EAAMC,SCfNC,EAAUD,SAASE,UAAUC,SAkCjC,SAASC,EAAiBC,GACzB,OAAOJ,EAAQK,KAAMD,EACtB,CCvBA,IAAAE,EAAA,CAAA,EAUAC,EAAAD,EAAA,WAAAP,GAUAQ,EAAAD,EAAA,kBAAAH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1aa0a8b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name Function -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/ctor} -*/ -setReadOnly( ns, 'Function', require( './../ctor' ) ); - -/** -* @name function2string -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/function/to-string} -*/ -setReadOnly( ns, 'function2string', require( './../to-string' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 10b4fca..7e98a44 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.3.3", "description": "Function.", "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": { - "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", @@ -35,38 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/utils": "github:stdlib-js/utils#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert": "github:stdlib-js/assert#main", - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/number": "github:stdlib-js/number#main", - "@stdlib/random": "github:stdlib-js/random#main", - "@stdlib/string": "github:stdlib-js/string#main", - "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", "standard", @@ -81,4 +27,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..5dd0a1d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9931b3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/thunk/README.md b/thunk/README.md deleted file mode 100644 index 842dd43..0000000 --- a/thunk/README.md +++ /dev/null @@ -1,134 +0,0 @@ - - -# thunk - -> Generate a [thunk][thunk]. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var thunk = require( '@stdlib/function/thunk' ); -``` - -#### thunk( fcn\[, ...args] ) - -Returns a [thunk][thunk] (i.e., an anonymous function having arity `0` and which invokes a provided function with specified arguments). - -```javascript -var add = require( '@stdlib/number/float64/base/add' ); - -var f = thunk( add, 2.0, 3.0 ); -// returns - -var v = f(); -// returns 5 - -// ... - -v = f(); -// returns 5 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var add = require( '@stdlib/number/float64/base/add' ); -var decorateAfter = require( '@stdlib/utils/decorate-after' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var thunk = require( '@stdlib/function/thunk' ); - -function log( v ) { - console.log( v ); -} - -// Create a PRNG for generating uniformly distributed pseudorandom integers: -var randi = discreteUniform( 100, 1000 ); - -// Randomly delay evaluation of various thunks... -var i; -for ( i = 0; i < 10; i++ ) { - setTimeout( decorateAfter( thunk( add, i, i+1 ), 0, log ), randi() ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/thunk/benchmark/benchmark.js b/thunk/benchmark/benchmark.js deleted file mode 100644 index 54a28e7..0000000 --- a/thunk/benchmark/benchmark.js +++ /dev/null @@ -1,72 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var pkg = require( './../package.json' ).name; -var thunk = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = thunk( abs, -0.0 ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::thunk', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = thunk( abs, -0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn(); // NOTE: this may get optimized away as returning the same value for each loop iteration - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( out ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/thunk/docs/repl.txt b/thunk/docs/repl.txt deleted file mode 100644 index 5f5afea..0000000 --- a/thunk/docs/repl.txt +++ /dev/null @@ -1,28 +0,0 @@ - -{{alias}}( fcn[, ...args] ) - Returns a thunk. - - Parameters - ---------- - fcn: Function - Function to convert to a thunk. - - args: ...any (optional) - Function arguments. - - Returns - ------- - out: Function - Thunk. - - Examples - -------- - > var fcn = {{alias}}( {{alias:@stdlib/number/float64/base/add}}, 2, 3 ); - > var v = fcn() - 5 - > v = fcn() - 5 - - See Also - -------- - diff --git a/thunk/docs/types/index.d.ts b/thunk/docs/types/index.d.ts deleted file mode 100644 index d2244b0..0000000 --- a/thunk/docs/types/index.d.ts +++ /dev/null @@ -1,45 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a thunk. -* -* @param fcn - function to convert to a thunk -* @param args - function args -* @returns thunk -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var f = thunk( add, 2, 3 ); -* // returns -* -* // ... -* -* // Evaluate the thunk: -* var v = f(); -* // returns 5 -*/ -declare function thunk, U>( fcn: ( ...args: T ) => U, ...args: T ): () => U; - - -// EXPORTS // - -export = thunk; diff --git a/thunk/docs/types/test.ts b/thunk/docs/types/test.ts deleted file mode 100644 index 357c664..0000000 --- a/thunk/docs/types/test.ts +++ /dev/null @@ -1,58 +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. -*/ - -import thunk = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - thunk<[], number>( (): number => 2 ); // $ExpectType () => number - thunk, number>( ( x: number ): number => x, 2 ); // $ExpectType () => number - thunk<[number, number], number>( ( x: number, y: number ): number => x + y, 2, 3 ); // $ExpectType () => number -} - -// The compiler throws an error if the function is provided a first argument which is not a function... -{ - thunk( true ); // $ExpectError - thunk( false ); // $ExpectError - thunk( 5 ); // $ExpectError - thunk( [] ); // $ExpectError - thunk( {} ); // $ExpectError - thunk( 'abc' ); // $ExpectError - - thunk( true, 2 ); // $ExpectError - thunk( false, 2 ); // $ExpectError - thunk( 5, 2 ); // $ExpectError - thunk( [], 2 ); // $ExpectError - thunk( {}, 2 ); // $ExpectError - thunk( 'abc', 2 ); // $ExpectError - - thunk( true, 2, 3 ); // $ExpectError - thunk( false, 2, 3 ); // $ExpectError - thunk( 5, 2, 3 ); // $ExpectError - thunk( [], 2, 3 ); // $ExpectError - thunk( {}, 2, 3 ); // $ExpectError - thunk( 'abc', 2, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided an incorrect number of arguments... -{ - thunk(); // $ExpectError -} diff --git a/thunk/examples/index.js b/thunk/examples/index.js deleted file mode 100644 index 1097300..0000000 --- a/thunk/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var add = require( '@stdlib/number/float64/base/add' ); -var decorateAfter = require( '@stdlib/utils/decorate-after' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var thunk = require( './../lib' ); - -function log( v ) { - console.log( v ); -} - -// Create a PRNG for generating uniformly distributed pseudorandom integers: -var randi = discreteUniform( 100, 1000 ); - -// Randomly delay evaluation of various thunks... -var i; -for ( i = 0; i < 10; i++ ) { - setTimeout( decorateAfter( thunk( add, i, i+1 ), 0, log ), randi() ); -} diff --git a/thunk/lib/index.js b/thunk/lib/index.js deleted file mode 100644 index 97f7df1..0000000 --- a/thunk/lib/index.js +++ /dev/null @@ -1,47 +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. -*/ - -'use strict'; - -/** -* Generate a thunk. -* -* @module @stdlib/function/thunk -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var thunk = require( '@stdlib/function/thunk' ); -* -* var f = thunk( add, 2, 3 ); -* // returns -* -* // ... -* -* // Evaluate the thunk: -* var v = f(); -* // returns 5 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/thunk/lib/main.js b/thunk/lib/main.js deleted file mode 100644 index 106b46e..0000000 --- a/thunk/lib/main.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert/is-function' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns a thunk. -* -* @param {Function} fcn - function to convert to a thunk -* @param {...*} [args] - function arguments -* @throws {TypeError} first argument must be a function -* @returns {Function} thunk -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var f = thunk( add, 2, 3 ); -* // returns -* -* // ... -* -* // Evaluate the thunk: -* var v = f(); -* // returns 5 -*/ -function thunk( fcn ) { - var args; - var i; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); - } - args = []; - for ( i = 1; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - // NOTE: we return an anonymous function to satisfy the definition of a thunk (i.e., an anonymous function which has no parameters of its own and wraps another function)... - return function () { // eslint-disable-line no-restricted-syntax, func-names - return fcn.apply( null, args ); - }; -} - - -// EXPORTS // - -module.exports = thunk; diff --git a/thunk/package.json b/thunk/package.json deleted file mode 100644 index 924a235..0000000 --- a/thunk/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/function/thunk", - "version": "0.0.0", - "description": "Generate a thunk.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdutils", - "stdutil", - "utilities", - "utils", - "util", - "thunk", - "delay", - "wrap", - "lazy", - "function", - "fun", - "func", - "fcn", - "functional" - ] -} diff --git a/thunk/test/test.js b/thunk/test/test.js deleted file mode 100644 index a6c16fb..0000000 --- a/thunk/test/test.js +++ /dev/null @@ -1,163 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var functionName = require( '@stdlib/utils/function-name' ); -var add = require( '@stdlib/number/float64/base/add' ); -var thunk = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof thunk, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - thunk( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a function (2 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - thunk( value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a function (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - thunk( value, 2, 3 ); - }; - } -}); - -tape( 'the function returns an anonymous function having arity 0', function test( t ) { - var fcn = thunk( add, 2, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns expected value' ); - t.strictEqual( functionName( fcn ), '', 'returns expected value' ); - t.strictEqual( fcn.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a thunk (nullary)', function test( t ) { - var fcn = thunk( constant ); - t.strictEqual( fcn(), 3.14, 'returns expected value' ); - t.strictEqual( fcn(), 3.14, 'returns expected value' ); - t.strictEqual( fcn(), 3.14, 'returns expected value' ); - t.end(); - - function constant() { - return 3.14; - } -}); - -tape( 'the function returns a thunk (unary)', function test( t ) { - var fcn = thunk( scale, 3.0 ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v + 1.0; - } -}); - -tape( 'the function returns a thunk (binary)', function test( t ) { - var fcn = thunk( add, 3.0, 1.0 ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.strictEqual( fcn(), 4.0, 'returns expected value' ); - t.end(); - - function add( x, y ) { - return x + y; - } -}); diff --git a/to-string/README.md b/to-string/README.md deleted file mode 100644 index 0740bbb..0000000 --- a/to-string/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# function2string - -> Return a string representing the source code of a provided function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var function2string = require( '@stdlib/function/to-string' ); -``` - -#### function2string( fcn ) - -Returns a string representing the source code of a provided function. - -```javascript -function add( x, y ) { - return x + y; -} - -var str = function2string( add ); -// e.g., returns 'function add( x, y ) {\n return x + y;\n}' -``` - -
- - - - - -
- -## Notes - -- If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: - - ```text - "function foo() { [native code] }" - ``` - - For intrinsic object methods and functions, `foo` is the initial name of the function. - -- If called on a function created by the [`Function`][@stdlib/function/ctor] constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. - -- Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. - -
- - - - - -
- -## Examples - - - -```javascript -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( '@stdlib/function/to-string' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-string/benchmark/benchmark.js b/to-string/benchmark/benchmark.js deleted file mode 100644 index 038c9f2..0000000 --- a/to-string/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var function2string = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var fcns; - var v; - var i; - - fcns = [ - add, - multiply - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = function2string( fcns[ i%fcns.length ] ); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function add( x, y ) { - return x + y; - } - - function multiply( x, y ) { - return x * y; - } -}); diff --git a/to-string/docs/repl.txt b/to-string/docs/repl.txt deleted file mode 100644 index 923f2c0..0000000 --- a/to-string/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( fcn ) - Returns a string representing the source code of a provided function. - - If called on built-in functions, functions created by `Function#bind()`, or - other non-JavaScript functions, the function returns a "native" function - string similar to the following: - - "function foo() { [native code] }" - - For intrinsic object methods and functions, `foo` is the initial name of the - function. - - If called on a function created by the `Function` constructor, the function - returns the source code of a synthesized function declaration having the - name "anonymous" and using the provided parameters and function body. - - Starting in ES2018, the ECMAScript specification requires that the returned - string contain the exact same source code as it was declared, including any - whitespace and/or comments. If the host is unable to access the source code, - the specification requires that the returned string be the native function - string. - - Parameters - ---------- - fcn: Function - Input function. - - Returns - ------- - out: string - String representing the function's source code. - - Examples - -------- - > {{alias}}( {{alias:@stdlib/math/base/special/erf}} ) - - - See Also - -------- - diff --git a/to-string/docs/types/index.d.ts b/to-string/docs/types/index.d.ts deleted file mode 100644 index 74b6c1d..0000000 --- a/to-string/docs/types/index.d.ts +++ /dev/null @@ -1,54 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param fcn - input function -* @returns string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -declare function function2string( fcn: Function ): string; - - -// EXPORTS // - -export = function2string; diff --git a/to-string/docs/types/test.ts b/to-string/docs/types/test.ts deleted file mode 100644 index 2b44e9c..0000000 --- a/to-string/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import function2string = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - function2string( function add( x: number, y: number ): number { return x + y; } ); // $ExpectType string -} - -// The compiler throws an error if the function is not provided a function... -{ - function2string( 'abc' ); // $ExpectError - function2string( 5 ); // $ExpectError - function2string( true ); // $ExpectError - function2string( false ); // $ExpectError - function2string( [] ); // $ExpectError - function2string( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - function2string(); // $ExpectError - function2string( function add( x: number, y: number ): number { return x + y; }, {} ); // $ExpectError -} diff --git a/to-string/examples/index.js b/to-string/examples/index.js deleted file mode 100644 index a76df97..0000000 --- a/to-string/examples/index.js +++ /dev/null @@ -1,42 +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. -*/ - -'use strict'; - -var ndarray = require( '@stdlib/ndarray/ctor' ); -var erf = require( '@stdlib/math/base/special/erf' ); -var daxpy = require( '@stdlib/blas/base/daxpy' ); -var kebabcase = require( '@stdlib/string/kebabcase' ); -var randu = require( '@stdlib/random/base/randu' ); -var format = require( '@stdlib/string/format' ); -var function2string = require( './../lib' ); - -var fcns = [ - [ 'ndarray', ndarray ], - [ 'erf', erf ], - [ 'daxpy', daxpy ], - [ 'kebabcase', kebabcase ], - [ 'randu', randu ], - [ 'format', format ], - [ 'function2string', function2string ] -]; - -var i; -for ( i = 0; i < fcns.length; i++ ) { - console.log( format( 'Function: %s\n\n%s\n', fcns[ i ][ 0 ], function2string( fcns[ i ][ 1 ] ) ) ); -} diff --git a/to-string/lib/index.js b/to-string/lib/index.js deleted file mode 100644 index b51985b..0000000 --- a/to-string/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Return a string representing the source code of a provided function. -* -* @module @stdlib/function/to-string -* -* @example -* var function2string = require( '@stdlib/function/to-string' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-string/lib/main.js b/to-string/lib/main.js deleted file mode 100644 index 9b3d3a2..0000000 --- a/to-string/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// VARIABLES // - -// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function: -var fcn2str = Function.prototype.toString; - - -// MAIN // - -/** -* Returns a string representing the source code of a provided function. -* -* ## Notes -* -* - If called on built-in functions, functions created by `Function.prototype.bind()`, or other non-JavaScript functions, the function returns a "native" function string similar to the following: -* -* ```text -* "function foo() { [native code] }" -* ``` -* -* For intrinsic object methods and functions, `foo` is the initial name of the function. -* -* - If called on a function created by the `Function` constructor, the function returns the source code of a synthesized function declaration having the name "anonymous" and using the provided parameters and function body. -* -* - Starting in ES2018, the ECMAScript specification requires that the returned string contain the exact same source code as it was declared, including any whitespace and/or comments. If the host is unable to access the source code, the specification requires that the returned string be the native function string. -* -* @param {Function} fcn - input function -* @throws {TypeError} must provide a function -* @returns {string} string representing function source code -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var str = function2string( add ); -* // e.g., returns 'function add( x, y ) {\n return x + y;\n}' -*/ -function function2string( fcn ) { - return fcn2str.call( fcn ); -} - - -// EXPORTS // - -module.exports = function2string; diff --git a/to-string/package.json b/to-string/package.json deleted file mode 100644 index fc0e27b..0000000 --- a/to-string/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/function/to-string", - "version": "0.0.0", - "description": "Return a string representing the source code of a provided function.", - "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": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "function", - "serialization", - "serialize", - "source", - "string", - "code" - ], - "__stdlib__": {} -} diff --git a/to-string/test/test.js b/to-string/test/test.js deleted file mode 100644 index bce3294..0000000 --- a/to-string/test/test.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var function2string = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof function2string, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {} - ]; - - 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() { - function2string( value ); - }; - } -}); - -tape( 'the function returns a string', function test( t ) { - var fcns; - var str; - var i; - - fcns = [ - tape, - function2string, - add - ]; - - for ( i = 0; i < fcns.length; i++ ) { - str = function2string( fcns[ i ] ); - - // NOTE: cannot perform more stringent tests, as pre-ES2018 environments were not required to return the exact source code as the original function declaration... - t.strictEqual( typeof str, 'string', 'returns expected value' ); - } - t.end(); - - function add( x, y ) { - return x + y; - } -});