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 cd973af..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-16T02:16:47.852Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d47aef8..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/cli) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 45b2a2b..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/cli) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 13ac9c6..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: '56 20 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var ns = require( '@stdlib/cli' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### ns @@ -96,11 +102,21 @@ The namespace contains the following: -```javascript -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( '@stdlib/cli' ); +```html + + + + + + + + ```
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 d3ed426..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/cli" -%% click B href "https://github.com/stdlib-js/cli/tree/main" -%% click C href "https://github.com/stdlib-js/cli/tree/production" -%% click D href "https://github.com/stdlib-js/cli/tree/esm" -%% click E href "https://github.com/stdlib-js/cli/tree/deno" -%% click F href "https://github.com/stdlib-js/cli/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/cli -[production-url]: https://github.com/stdlib-js/cli/tree/production -[deno-url]: https://github.com/stdlib-js/cli/tree/deno -[deno-readme]: https://github.com/stdlib-js/cli/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/cli/tree/umd -[umd-readme]: https://github.com/stdlib-js/cli/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/cli/tree/esm -[esm-readme]: https://github.com/stdlib-js/cli/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..03231f6 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).ns=t()}(this,(function(){"use strict";var e="function"==typeof Object.defineProperty?Object.defineProperty:null;var t=Object.defineProperty;function r(e){return"number"==typeof e}function n(e){var t,r="";for(t=0;t0&&(r-=1),n=e.toExponential(r)):n=e.toPrecision(t.precision),t.alternate||(n=u.call(n,y,"$1e"),n=u.call(n,b,"e"),n=u.call(n,v,""));break;default:throw new Error("invalid double notation. Value: "+t.specifier)}return n=u.call(n,f,"e+0$1"),n=u.call(n,g,"e-0$1"),t.alternate&&(n=u.call(n,h,"$1."),n=u.call(n,d,"$1.e")),e>=0&&t.sign&&(n=t.sign+n),n=t.specifier===p.call(t.specifier)?p.call(n):c.call(n)}function m(e){var t,r="";for(t=0;t127)throw new Error("invalid character code. Value: "+i.arg);i.arg=_(l)?String(i.arg):k(l)}break;case"e":case"E":case"f":case"F":case"g":case"G":if(t||(i.precision=6),u=parseFloat(i.arg),!isFinite(u)){if(!r(i.arg))throw new Error("invalid floating-point number. Value: "+c);u=i.arg,i.padZeros=!1}i.arg=w(u,i);break;default:throw new Error("invalid specifier: "+i.specifier)}i.maxWidth>=0&&i.arg.length>i.maxWidth&&(i.arg=i.arg.substring(0,i.maxWidth)),i.padZeros?i.arg=o(i.arg,i.width||i.precision,i.padRight):i.width&&(i.arg=(h=i.arg,d=i.width,v=i.padRight,b=void 0,(b=d-h.length)<0?h:h=v?h+m(b):m(b)+h)),c+=i.arg||"",p+=1}return c}var j=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function O(e){var t={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(t.precision="1"),t}function A(e){var t,r,n,o;for(r=[],o=0,n=j.exec(e);n;)(t=e.slice(o,j.lastIndex-n[0].length)).length&&r.push(t),"%"===n[6]?r.push("%"):r.push(O(n)),o=j.lastIndex,n=j.exec(e);return(t=e.slice(o)).length&&r.push(t),r}function S(e){var t,r;if("string"!=typeof e)throw new TypeError(S("invalid argument. First argument must be a string. Value: `%s`.",e));for(t=[A(e)],r=1;r1)for(var r=1;r0||r[1]>10?e.exitCode=t:(e.exitCode=t,setTimeout((function(){e.exit(t)}),10))}function Ze(){return this instanceof Ze?this:new Ze}Ie=Ze.prototype,M(Ie,"notify",{configurable:!1,enumerable:!1,writable:!1,value:function(){}});var Re=function(e,t){t||(t={});var r={bools:{},strings:{},unknownFn:null};"function"==typeof t.unknown&&(r.unknownFn=t.unknown),"boolean"==typeof t.boolean&&t.boolean?r.allBools=!0:[].concat(t.boolean).filter(Boolean).forEach((function(e){r.bools[e]=!0}));var n={};function o(e){return n[e].some((function(e){return r.bools[e]}))}Object.keys(t.alias||{}).forEach((function(e){n[e]=[].concat(t.alias[e]),n[e].forEach((function(t){n[t]=[e].concat(n[e].filter((function(e){return t!==e})))}))})),[].concat(t.string).filter(Boolean).forEach((function(e){r.strings[e]=!0,n[e]&&[].concat(n[e]).forEach((function(e){r.strings[e]=!0}))}));var i=t.default||{},a={_:[]};function s(e,t,n){for(var o=e,i=0;i1){if("number"!=typeof t||!U(t)||t<0)throw new TypeError(S("invalid argument. Second argument must be a nonnegative integer. Value: `%s`.",t));r=t}else r=1;Pe.error("Error: %s",e.message),Ne(Le,r)})),We(De.prototype,"exit",(function(e){if(0===arguments.length)return Le.exit(0);if("number"!=typeof e||!U(e)||e<0)throw new TypeError(S("invalid argument. Must provide a nonnegative integer. Value: `%s`.",e));Le.exit(e)}));var Ge={};return function(e,t,r){M(e,t,{configurable:!1,enumerable:!0,writable:!1,value:r})}(Ge,"CLI",De),Ge})); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..f7ac790 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../node_modules/@stdlib/utils/define-property/lib/define_property.js","../node_modules/@stdlib/utils/define-property/lib/builtin.js","../node_modules/@stdlib/string/base/format-interpolate/lib/is_number.js","../node_modules/@stdlib/string/base/format-interpolate/lib/zero_pad.js","../node_modules/@stdlib/string/base/format-interpolate/lib/format_integer.js","../node_modules/@stdlib/string/base/format-interpolate/lib/format_double.js","../node_modules/@stdlib/string/base/format-interpolate/lib/space_pad.js","../node_modules/@stdlib/string/base/format-interpolate/lib/main.js","../node_modules/@stdlib/string/base/format-interpolate/lib/is_string.js","../node_modules/@stdlib/string/base/format-tokenize/lib/main.js","../node_modules/@stdlib/string/format/lib/main.js","../node_modules/@stdlib/string/format/lib/is_string.js","../node_modules/@stdlib/utils/define-property/lib/polyfill.js","../node_modules/@stdlib/utils/define-property/lib/index.js","../node_modules/@stdlib/utils/define-property/lib/has_define_property_support.js","../node_modules/minimist/index.js","../ctor/lib/is_integer.js","../ctor/lib/validate.js","../node_modules/@stdlib/utils/define-nonenumerable-read-only-property/lib/main.js","../ctor/lib/process.js","../ctor/lib/console.js","../ctor/lib/exit_code.js","../ctor/lib/notifier.js","../node_modules/@stdlib/utils/noop/lib/main.js","../ctor/lib/main.js","../lib/index.js","../node_modules/@stdlib/utils/define-read-only-property/lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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\nvar main = ( typeof Object.defineProperty === 'function' ) ? Object.defineProperty : null;\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Defines (or modifies) an object property.\n*\n* ## Notes\n*\n* - Property descriptors come in two flavors: **data descriptors** and **accessor descriptors**. A data descriptor is a property that has a value, which may or may not be writable. An accessor descriptor is a property described by a getter-setter function pair. A descriptor must be one of these two flavors and cannot be both.\n*\n* @name defineProperty\n* @type {Function}\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {Object} descriptor - property descriptor\n* @param {boolean} [descriptor.configurable=false] - boolean indicating if property descriptor can be changed and if the property can be deleted from the provided object\n* @param {boolean} [descriptor.enumerable=false] - boolean indicating if the property shows up when enumerating object properties\n* @param {boolean} [descriptor.writable=false] - boolean indicating if the value associated with the property can be changed with an assignment operator\n* @param {*} [descriptor.value] - property value\n* @param {(Function|void)} [descriptor.get=undefined] - function which serves as a getter for the property, or, if no getter, undefined. When the property is accessed, a getter function is called without arguments and with the `this` context set to the object through which the property is accessed (which may not be the object on which the property is defined due to inheritance). The return value will be used as the property value.\n* @param {(Function|void)} [descriptor.set=undefined] - function which serves as a setter for the property, or, if no setter, undefined. When assigning a property value, a setter function is called with one argument (the value being assigned to the property) and with the `this` context set to the object through which the property is assigned.\n* @throws {TypeError} first argument must be an object\n* @throws {TypeError} third argument must be an object\n* @throws {Error} property descriptor cannot have both a value and a setter and/or getter\n* @returns {Object} object with added property\n*\n* @example\n* var obj = {};\n*\n* defineProperty( obj, 'foo', {\n* 'value': 'bar'\n* });\n*\n* var str = obj.foo;\n* // returns 'bar'\n*/\nvar defineProperty = Object.defineProperty;\n\n\n// EXPORTS //\n\nexport default defineProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a number primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number primitive\n*\n* @example\n* var bool = isNumber( 3.14 );\n* // returns true\n*\n* @example\n* var bool = isNumber( NaN );\n* // returns true\n*\n* @example\n* var bool = isNumber( new Number( 3.14 ) );\n* // returns false\n*/\nfunction isNumber( value ) {\n\treturn ( typeof value === 'number' ); // NOTE: we inline the `isNumber.isPrimitive` function from `@stdlib/assert/is-number` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Tests if a string starts with a minus sign (`-`).\n*\n* @private\n* @param {string} str - input string\n* @returns {boolean} boolean indicating if a string starts with a minus sign (`-`)\n*/\nfunction startsWithMinus( str ) {\n\treturn str[ 0 ] === '-';\n}\n\n/**\n* Returns a string of `n` zeros.\n*\n* @private\n* @param {number} n - number of zeros\n* @returns {string} string of zeros\n*/\nfunction zeros( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += '0';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with zeros to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction zeroPad( str, width, right ) {\n\tvar negative = false;\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tif ( startsWithMinus( str ) ) {\n\t\tnegative = true;\n\t\tstr = str.substr( 1 );\n\t}\n\tstr = ( right ) ?\n\t\tstr + zeros( pad ) :\n\t\tzeros( pad ) + str;\n\tif ( negative ) {\n\t\tstr = '-' + str;\n\t}\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default zeroPad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isNumber from './is_number.js';\nimport zeroPad from './zero_pad.js';\n\n// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies.\nvar lowercase = String.prototype.toLowerCase;\nvar uppercase = String.prototype.toUpperCase;\n\n\n// MAIN //\n\n/**\n* Formats a token object argument as an integer.\n*\n* @private\n* @param {Object} token - token object\n* @throws {Error} must provide a valid integer\n* @returns {string} formatted token argument\n*/\nfunction formatInteger( token ) {\n\tvar base;\n\tvar out;\n\tvar i;\n\n\tswitch ( token.specifier ) {\n\tcase 'b':\n\t\t// Case: %b (binary)\n\t\tbase = 2;\n\t\tbreak;\n\tcase 'o':\n\t\t// Case: %o (octal)\n\t\tbase = 8;\n\t\tbreak;\n\tcase 'x':\n\tcase 'X':\n\t\t// Case: %x, %X (hexadecimal)\n\t\tbase = 16;\n\t\tbreak;\n\tcase 'd':\n\tcase 'i':\n\tcase 'u':\n\tdefault:\n\t\t// Case: %d, %i, %u (decimal)\n\t\tbase = 10;\n\t\tbreak;\n\t}\n\tout = token.arg;\n\ti = parseInt( out, 10 );\n\tif ( !isFinite( i ) ) { // NOTE: We use the global `isFinite` function here instead of `@stdlib/math/base/assert/is-finite` in order to avoid circular dependencies.\n\t\tif ( !isNumber( out ) ) {\n\t\t\tthrow new Error( 'invalid integer. Value: ' + out );\n\t\t}\n\t\ti = 0;\n\t}\n\tif ( i < 0 && ( token.specifier === 'u' || base !== 10 ) ) {\n\t\ti = 0xffffffff + i + 1;\n\t}\n\tif ( i < 0 ) {\n\t\tout = ( -i ).toString( base );\n\t\tif ( token.precision ) {\n\t\t\tout = zeroPad( out, token.precision, token.padRight );\n\t\t}\n\t\tout = '-' + out;\n\t} else {\n\t\tout = i.toString( base );\n\t\tif ( !i && !token.precision ) {\n\t\t\tout = '';\n\t\t} else if ( token.precision ) {\n\t\t\tout = zeroPad( out, token.precision, token.padRight );\n\t\t}\n\t\tif ( token.sign ) {\n\t\t\tout = token.sign + out;\n\t\t}\n\t}\n\tif ( base === 16 ) {\n\t\tif ( token.alternate ) {\n\t\t\tout = '0x' + out;\n\t\t}\n\t\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\t\tuppercase.call( out ) :\n\t\t\tlowercase.call( out );\n\t}\n\tif ( base === 8 ) {\n\t\tif ( token.alternate && out.charAt( 0 ) !== '0' ) {\n\t\t\tout = '0' + out;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\n// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies.\nvar abs = Math.abs; // eslint-disable-line stdlib/no-builtin-math\nvar lowercase = String.prototype.toLowerCase;\nvar uppercase = String.prototype.toUpperCase;\nvar replace = String.prototype.replace;\n\n\n// VARIABLES //\n\nvar RE_EXP_POS_DIGITS = /e\\+(\\d)$/;\nvar RE_EXP_NEG_DIGITS = /e-(\\d)$/;\nvar RE_ONLY_DIGITS = /^(\\d+)$/;\nvar RE_DIGITS_BEFORE_EXP = /^(\\d+)e/;\nvar RE_TRAILING_PERIOD_ZERO = /\\.0$/;\nvar RE_PERIOD_ZERO_EXP = /\\.0*e/;\nvar RE_ZERO_BEFORE_EXP = /(\\..*[^0])0*e/;\n\n\n// MAIN //\n\n/**\n* Formats a token object argument as a floating-point number.\n*\n* @private\n* @param {number} f - parsed number\n* @param {Object} token - token object\n* @throws {Error} must provide a valid floating-point number\n* @returns {string} formatted token argument\n*/\nfunction formatDouble( f, token ) {\n\tvar digits;\n\tvar out;\n\n\tswitch ( token.specifier ) {\n\tcase 'e':\n\tcase 'E':\n\t\tout = f.toExponential( token.precision );\n\t\tbreak;\n\tcase 'f':\n\tcase 'F':\n\t\tout = f.toFixed( token.precision );\n\t\tbreak;\n\tcase 'g':\n\tcase 'G':\n\t\tif ( abs( f ) < 0.0001 ) {\n\t\t\tdigits = token.precision;\n\t\t\tif ( digits > 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport isNumber from './is_number.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar f;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\tf = parseFloat( token.arg );\n\t\t\t\tif ( !isFinite( f ) ) { // NOTE: We use the global `isFinite` function here instead of `@stdlib/math/base/assert/is-finite` in order to avoid circular dependencies.\n\t\t\t\t\tif ( !isNumber( token.arg ) ) {\n\t\t\t\t\t\tthrow new Error( 'invalid floating-point number. Value: ' + out );\n\t\t\t\t\t}\n\t\t\t\t\t// Case: NaN, Infinity, or -Infinity\n\t\t\t\t\tf = token.arg;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( f, token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\t// Check for an escaped percent sign `%%`...\n\t\tif ( match[ 6 ] === '%' ) {\n\t\t\ttokens.push( '%' );\n\t\t} else {\n\t\t\ttokens.push( parse( match ) );\n\t\t}\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport interpolate from './../../base/format-interpolate';\nimport tokenize from './../../base/format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-underscore-dangle, no-proto */\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar objectProtoype = Object.prototype;\nvar toStr = objectProtoype.toString;\nvar defineGetter = objectProtoype.__defineGetter__;\nvar defineSetter = objectProtoype.__defineSetter__;\nvar lookupGetter = objectProtoype.__lookupGetter__;\nvar lookupSetter = objectProtoype.__lookupSetter__;\n\n\n// MAIN //\n\n/**\n* Defines (or modifies) an object property.\n*\n* ## Notes\n*\n* - Property descriptors come in two flavors: **data descriptors** and **accessor descriptors**. A data descriptor is a property that has a value, which may or may not be writable. An accessor descriptor is a property described by a getter-setter function pair. A descriptor must be one of these two flavors and cannot be both.\n*\n* @param {Object} obj - object on which to define the property\n* @param {string} prop - property name\n* @param {Object} descriptor - property descriptor\n* @param {boolean} [descriptor.configurable=false] - boolean indicating if property descriptor can be changed and if the property can be deleted from the provided object\n* @param {boolean} [descriptor.enumerable=false] - boolean indicating if the property shows up when enumerating object properties\n* @param {boolean} [descriptor.writable=false] - boolean indicating if the value associated with the property can be changed with an assignment operator\n* @param {*} [descriptor.value] - property value\n* @param {(Function|void)} [descriptor.get=undefined] - function which serves as a getter for the property, or, if no getter, undefined. When the property is accessed, a getter function is called without arguments and with the `this` context set to the object through which the property is accessed (which may not be the object on which the property is defined due to inheritance). The return value will be used as the property value.\n* @param {(Function|void)} [descriptor.set=undefined] - function which serves as a setter for the property, or, if no setter, undefined. When assigning a property value, a setter function is called with one argument (the value being assigned to the property) and with the `this` context set to the object through which the property is assigned.\n* @throws {TypeError} first argument must be an object\n* @throws {TypeError} third argument must be an object\n* @throws {Error} property descriptor cannot have both a value and a setter and/or getter\n* @returns {Object} object with added property\n*\n* @example\n* var obj = {};\n*\n* defineProperty( obj, 'foo', {\n* 'value': 'bar'\n* });\n*\n* var str = obj.foo;\n* // returns 'bar'\n*/\nfunction defineProperty( obj, prop, descriptor ) {\n\tvar prototype;\n\tvar hasValue;\n\tvar hasGet;\n\tvar hasSet;\n\n\tif ( typeof obj !== 'object' || obj === null || toStr.call( obj ) === '[object Array]' ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) );\n\t}\n\tif ( typeof descriptor !== 'object' || descriptor === null || toStr.call( descriptor ) === '[object Array]' ) {\n\t\tthrow new TypeError( format( 'invalid argument. Property descriptor must be an object. Value: `%s`.', descriptor ) );\n\t}\n\thasValue = ( 'value' in descriptor );\n\tif ( hasValue ) {\n\t\tif (\n\t\t\tlookupGetter.call( obj, prop ) ||\n\t\t\tlookupSetter.call( obj, prop )\n\t\t) {\n\t\t\t// Override `__proto__` to avoid touching inherited accessors:\n\t\t\tprototype = obj.__proto__;\n\t\t\tobj.__proto__ = objectProtoype;\n\n\t\t\t// Delete property as existing getters/setters prevent assigning value to specified property:\n\t\t\tdelete obj[ prop ];\n\t\t\tobj[ prop ] = descriptor.value;\n\n\t\t\t// Restore original prototype:\n\t\t\tobj.__proto__ = prototype;\n\t\t} else {\n\t\t\tobj[ prop ] = descriptor.value;\n\t\t}\n\t}\n\thasGet = ( 'get' in descriptor );\n\thasSet = ( 'set' in descriptor );\n\n\tif ( hasValue && ( hasGet || hasSet ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot specify one or more accessors and a value or writable attribute in the property descriptor.' );\n\t}\n\n\tif ( hasGet && defineGetter ) {\n\t\tdefineGetter.call( obj, prop, descriptor.get );\n\t}\n\tif ( hasSet && defineSetter ) {\n\t\tdefineSetter.call( obj, prop, descriptor.set );\n\t}\n\treturn obj;\n}\n\n\n// EXPORTS //\n\nexport default defineProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Define (or modify) an object property.\n*\n* @module @stdlib/utils/define-property\n*\n* @example\n* import defineProperty from '@stdlib/utils/define-property';\n*\n* var obj = {};\n* defineProperty( obj, 'foo', {\n* 'value': 'bar',\n* 'writable': false,\n* 'configurable': false,\n* 'enumerable': false\n* });\n* obj.foo = 'boop'; // => throws\n*/\n\n// MODULES //\n\nimport hasDefinePropertySupport from './has_define_property_support.js';\nimport builtin from './builtin.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar defineProperty;\nif ( hasDefinePropertySupport() ) {\n\tdefineProperty = builtin;\n} else {\n\tdefineProperty = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default defineProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './define_property.js';\n\n\n// MAIN //\n\n/**\n* Tests for `Object.defineProperty` support.\n*\n* @private\n* @returns {boolean} boolean indicating if an environment has `Object.defineProperty` support\n*\n* @example\n* var bool = hasDefinePropertySupport();\n* // returns \n*/\nfunction hasDefinePropertySupport() {\n\t// Test basic support...\n\ttry {\n\t\tdefineProperty( {}, 'x', {} );\n\t\treturn true;\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default hasDefinePropertySupport;\n","'use strict';\n\nfunction hasKey(obj, keys) {\n\tvar o = obj;\n\tkeys.slice(0, -1).forEach(function (key) {\n\t\to = o[key] || {};\n\t});\n\n\tvar key = keys[keys.length - 1];\n\treturn key in o;\n}\n\nfunction isNumber(x) {\n\tif (typeof x === 'number') { return true; }\n\tif ((/^0x[0-9a-f]+$/i).test(x)) { return true; }\n\treturn (/^[-+]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(e[-+]?\\d+)?$/).test(x);\n}\n\nfunction isConstructorOrProto(obj, key) {\n\treturn (key === 'constructor' && typeof obj[key] === 'function') || key === '__proto__';\n}\n\nmodule.exports = function (args, opts) {\n\tif (!opts) { opts = {}; }\n\n\tvar flags = {\n\t\tbools: {},\n\t\tstrings: {},\n\t\tunknownFn: null,\n\t};\n\n\tif (typeof opts.unknown === 'function') {\n\t\tflags.unknownFn = opts.unknown;\n\t}\n\n\tif (typeof opts.boolean === 'boolean' && opts.boolean) {\n\t\tflags.allBools = true;\n\t} else {\n\t\t[].concat(opts.boolean).filter(Boolean).forEach(function (key) {\n\t\t\tflags.bools[key] = true;\n\t\t});\n\t}\n\n\tvar aliases = {};\n\n\tfunction aliasIsBoolean(key) {\n\t\treturn aliases[key].some(function (x) {\n\t\t\treturn flags.bools[x];\n\t\t});\n\t}\n\n\tObject.keys(opts.alias || {}).forEach(function (key) {\n\t\taliases[key] = [].concat(opts.alias[key]);\n\t\taliases[key].forEach(function (x) {\n\t\t\taliases[x] = [key].concat(aliases[key].filter(function (y) {\n\t\t\t\treturn x !== y;\n\t\t\t}));\n\t\t});\n\t});\n\n\t[].concat(opts.string).filter(Boolean).forEach(function (key) {\n\t\tflags.strings[key] = true;\n\t\tif (aliases[key]) {\n\t\t\t[].concat(aliases[key]).forEach(function (k) {\n\t\t\t\tflags.strings[k] = true;\n\t\t\t});\n\t\t}\n\t});\n\n\tvar defaults = opts.default || {};\n\n\tvar argv = { _: [] };\n\n\tfunction argDefined(key, arg) {\n\t\treturn (flags.allBools && (/^--[^=]+$/).test(arg))\n\t\t\t|| flags.strings[key]\n\t\t\t|| flags.bools[key]\n\t\t\t|| aliases[key];\n\t}\n\n\tfunction setKey(obj, keys, value) {\n\t\tvar o = obj;\n\t\tfor (var i = 0; i < keys.length - 1; i++) {\n\t\t\tvar key = keys[i];\n\t\t\tif (isConstructorOrProto(o, key)) { return; }\n\t\t\tif (o[key] === undefined) { o[key] = {}; }\n\t\t\tif (\n\t\t\t\to[key] === Object.prototype\n\t\t\t\t|| o[key] === Number.prototype\n\t\t\t\t|| o[key] === String.prototype\n\t\t\t) {\n\t\t\t\to[key] = {};\n\t\t\t}\n\t\t\tif (o[key] === Array.prototype) { o[key] = []; }\n\t\t\to = o[key];\n\t\t}\n\n\t\tvar lastKey = keys[keys.length - 1];\n\t\tif (isConstructorOrProto(o, lastKey)) { return; }\n\t\tif (\n\t\t\to === Object.prototype\n\t\t\t|| o === Number.prototype\n\t\t\t|| o === String.prototype\n\t\t) {\n\t\t\to = {};\n\t\t}\n\t\tif (o === Array.prototype) { o = []; }\n\t\tif (o[lastKey] === undefined || flags.bools[lastKey] || typeof o[lastKey] === 'boolean') {\n\t\t\to[lastKey] = value;\n\t\t} else if (Array.isArray(o[lastKey])) {\n\t\t\to[lastKey].push(value);\n\t\t} else {\n\t\t\to[lastKey] = [o[lastKey], value];\n\t\t}\n\t}\n\n\tfunction setArg(key, val, arg) {\n\t\tif (arg && flags.unknownFn && !argDefined(key, arg)) {\n\t\t\tif (flags.unknownFn(arg) === false) { return; }\n\t\t}\n\n\t\tvar value = !flags.strings[key] && isNumber(val)\n\t\t\t? Number(val)\n\t\t\t: val;\n\t\tsetKey(argv, key.split('.'), value);\n\n\t\t(aliases[key] || []).forEach(function (x) {\n\t\t\tsetKey(argv, x.split('.'), value);\n\t\t});\n\t}\n\n\tObject.keys(flags.bools).forEach(function (key) {\n\t\tsetArg(key, defaults[key] === undefined ? false : defaults[key]);\n\t});\n\n\tvar notFlags = [];\n\n\tif (args.indexOf('--') !== -1) {\n\t\tnotFlags = args.slice(args.indexOf('--') + 1);\n\t\targs = args.slice(0, args.indexOf('--'));\n\t}\n\n\tfor (var i = 0; i < args.length; i++) {\n\t\tvar arg = args[i];\n\t\tvar key;\n\t\tvar next;\n\n\t\tif ((/^--.+=/).test(arg)) {\n\t\t\t// Using [\\s\\S] instead of . because js doesn't support the\n\t\t\t// 'dotall' regex modifier. See:\n\t\t\t// http://stackoverflow.com/a/1068308/13216\n\t\t\tvar m = arg.match(/^--([^=]+)=([\\s\\S]*)$/);\n\t\t\tkey = m[1];\n\t\t\tvar value = m[2];\n\t\t\tif (flags.bools[key]) {\n\t\t\t\tvalue = value !== 'false';\n\t\t\t}\n\t\t\tsetArg(key, value, arg);\n\t\t} else if ((/^--no-.+/).test(arg)) {\n\t\t\tkey = arg.match(/^--no-(.+)/)[1];\n\t\t\tsetArg(key, false, arg);\n\t\t} else if ((/^--.+/).test(arg)) {\n\t\t\tkey = arg.match(/^--(.+)/)[1];\n\t\t\tnext = args[i + 1];\n\t\t\tif (\n\t\t\t\tnext !== undefined\n\t\t\t\t&& !(/^(-|--)[^-]/).test(next)\n\t\t\t\t&& !flags.bools[key]\n\t\t\t\t&& !flags.allBools\n\t\t\t\t&& (aliases[key] ? !aliasIsBoolean(key) : true)\n\t\t\t) {\n\t\t\t\tsetArg(key, next, arg);\n\t\t\t\ti += 1;\n\t\t\t} else if ((/^(true|false)$/).test(next)) {\n\t\t\t\tsetArg(key, next === 'true', arg);\n\t\t\t\ti += 1;\n\t\t\t} else {\n\t\t\t\tsetArg(key, flags.strings[key] ? '' : true, arg);\n\t\t\t}\n\t\t} else if ((/^-[^-]+/).test(arg)) {\n\t\t\tvar letters = arg.slice(1, -1).split('');\n\n\t\t\tvar broken = false;\n\t\t\tfor (var j = 0; j < letters.length; j++) {\n\t\t\t\tnext = arg.slice(j + 2);\n\n\t\t\t\tif (next === '-') {\n\t\t\t\t\tsetArg(letters[j], next, arg);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif ((/[A-Za-z]/).test(letters[j]) && next[0] === '=') {\n\t\t\t\t\tsetArg(letters[j], next.slice(1), arg);\n\t\t\t\t\tbroken = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t(/[A-Za-z]/).test(letters[j])\n\t\t\t\t\t&& (/-?\\d+(\\.\\d*)?(e-?\\d+)?$/).test(next)\n\t\t\t\t) {\n\t\t\t\t\tsetArg(letters[j], next, arg);\n\t\t\t\t\tbroken = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (letters[j + 1] && letters[j + 1].match(/\\W/)) {\n\t\t\t\t\tsetArg(letters[j], arg.slice(j + 2), arg);\n\t\t\t\t\tbroken = true;\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tsetArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tkey = arg.slice(-1)[0];\n\t\t\tif (!broken && key !== '-') {\n\t\t\t\tif (\n\t\t\t\t\targs[i + 1]\n\t\t\t\t\t&& !(/^(-|--)[^-]/).test(args[i + 1])\n\t\t\t\t\t&& !flags.bools[key]\n\t\t\t\t\t&& (aliases[key] ? !aliasIsBoolean(key) : true)\n\t\t\t\t) {\n\t\t\t\t\tsetArg(key, args[i + 1], arg);\n\t\t\t\t\ti += 1;\n\t\t\t\t} else if (args[i + 1] && (/^(true|false)$/).test(args[i + 1])) {\n\t\t\t\t\tsetArg(key, args[i + 1] === 'true', arg);\n\t\t\t\t\ti += 1;\n\t\t\t\t} else {\n\t\t\t\t\tsetArg(key, flags.strings[key] ? '' : true, arg);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (!flags.unknownFn || flags.unknownFn(arg) !== false) {\n\t\t\t\targv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));\n\t\t\t}\n\t\t\tif (opts.stopEarly) {\n\t\t\t\targv._.push.apply(argv._, args.slice(i + 1));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tObject.keys(defaults).forEach(function (k) {\n\t\tif (!hasKey(argv, k.split('.'))) {\n\t\t\tsetKey(argv, k.split('.'), defaults[k]);\n\n\t\t\t(aliases[k] || []).forEach(function (x) {\n\t\t\t\tsetKey(argv, x.split('.'), defaults[k]);\n\t\t\t});\n\t\t}\n\t});\n\n\tif (opts['--']) {\n\t\targv['--'] = notFlags.slice();\n\t} else {\n\t\tnotFlags.forEach(function (k) {\n\t\t\targv._.push(k);\n\t\t});\n\t}\n\n\treturn argv;\n};\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a finite double-precision floating-point number is an integer.\n*\n* @private\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is an integer\n*\n* @example\n* var bool = isInteger( 1.0 );\n* // returns true\n*\n* @example\n* var bool = isInteger( 3.14 );\n* // returns false\n*/\nfunction isInteger( x ) {\n\t// NOTE: we explicitly avoid using `@stdlib/math/base/special` here in order to avoid circular dependencies.\n\treturn ( Math.floor( x ) === x ); // eslint-disable-line stdlib/no-builtin-math\n}\n\n\n// EXPORTS //\n\nexport default isInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar hasOwnProp = Object.prototype.hasOwnProperty;\nvar isArray = Array.isArray;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {Object} [options.pkg] - package meta information (package.json)\n* @param {string} [options.version] - command-line interface version\n* @param {string} [options.help] - help text\n* @param {(string|boolean)} [options.title] - process title or a boolean indicating whether to set the process title\n* @param {boolean} [options.updates] - boolean indicating whether to check if a command-line interface is an outdated version\n* @param {Array} [options.argv] - command-line arguments\n* @param {Options} [options.options] - command-line interface options\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'pkg': {},\n* 'version': '1.0.0',\n* 'help': 'Usage: beep [options] ',\n* 'title': 'foo',\n* 'updates': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( typeof options !== 'object' || options === null || isArray( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp.call( options, 'pkg' ) ) {\n\t\topts.pkg = options.pkg;\n\t\tif ( typeof opts.pkg !== 'object' || opts.pkg === null || isArray( opts.pkg ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an object. Option: `%s`.', 'pkg', opts.pkg ) );\n\t\t}\n\t}\n\tif ( hasOwnProp.call( options, 'help' ) ) {\n\t\topts.help = options.help;\n\t\tif ( typeof opts.help !== 'string' ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'help', opts.help ) );\n\t\t}\n\t}\n\tif ( hasOwnProp.call( options, 'version' ) ) {\n\t\topts.version = options.version;\n\t\tif ( typeof opts.version !== 'string' ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'version', opts.version ) );\n\t\t}\n\t}\n\tif ( hasOwnProp.call( options, 'title' ) ) {\n\t\topts.title = options.title;\n\t\tif ( typeof opts.title !== 'string' && typeof opts.title !== 'boolean' ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either a string or boolean primitive. Option: `%s`.', 'title', opts.title ) );\n\t\t}\n\t}\n\tif ( hasOwnProp.call( options, 'updates' ) ) {\n\t\topts.updates = options.updates;\n\t\tif ( typeof opts.updates !== 'boolean' ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'updates', opts.updates ) );\n\t\t}\n\t}\n\tif ( hasOwnProp.call( options, 'argv' ) ) {\n\t\topts.argv = options.argv;\n\t\tif ( !isArray( opts.argv ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array. Option: `%s`.', 'argv', opts.argv ) );\n\t\t}\n\t}\n\tif ( hasOwnProp.call( options, 'options' ) ) {\n\t\topts.options = options.options;\n\t\tif ( typeof opts.options !== 'object' || opts.options === null || isArray( opts.options ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a plain object. Option: `%s`.', 'options', opts.options ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a non-enumerable read-only property.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {*} value - value to set\n*\n* @example\n* var obj = {};\n*\n* setNonEnumerableReadOnly( obj, 'foo', 'bar' );\n*\n* try {\n* obj.foo = 'boop';\n* } catch ( err ) {\n* console.error( err.message );\n* }\n*/\nfunction setNonEnumerableReadOnly( obj, prop, value ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': false,\n\t\t'writable': false,\n\t\t'value': value\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setNonEnumerableReadOnly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar proc = require( 'process' );\n\n\n// EXPORTS //\n\nexport default proc;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// EXPORTS //\n\nexport default console;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport proc from './process.js';\n\n\n// VARIABLES //\n\nvar NODE_VERSION = proc.versions.node;\nvar TIMEOUT = 10; // ms\n\n\n// MAIN //\n\n/**\n* Sets the process exit code.\n*\n* @private\n* @param {Object} proc - process object\n* @param {NonNegativeInteger} code - exit code\n* @returns {void}\n*/\nfunction exitCode( proc, code ) {\n\tvar v;\n\n\t// Handle old Node.js versions lacking `process.exitCode` support...\n\tv = NODE_VERSION.split( '.' );\n\tv[ 0 ] = parseInt( v[ 0 ], 10 );\n\tv[ 1 ] = parseInt( v[ 1 ], 10 );\n\n\t// Case: >0.x.x\n\tif ( v[ 0 ] > 0 ) {\n\t\tproc.exitCode = code;\n\t\treturn;\n\t}\n\t// Case: >0.10.x\n\tif ( v[ 1 ] > 10 ) {\n\t\tproc.exitCode = code;\n\t\treturn;\n\t}\n\t// Case: <= 0.10.x\n\tproc.exitCode = code; // NOTE: assigning this property should have no operational effect in older Node.js versions\n\n\t// No choice but to forcefully exit during a subsequent turn of the event loop (note: the timeout duration is arbitrary; the main idea is to hopefully allow the event loop queue to drain before exiting the process, including the flushing of stdio streams which can be non-blocking/asynchronous)...\n\tsetTimeout( onTimeout, TIMEOUT );\n\n\t/**\n\t* Callback invoked during a subsequent turn of the event loop.\n\t*\n\t* @private\n\t*/\n\tfunction onTimeout() {\n\t\tproc.exit( code );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default exitCode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n// FIXME: remove this stub and create a stdlib equivalent of update-notifier\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport noop from '@stdlib/utils/noop';\n\n\n// MAIN //\n\n/**\n* Notifier constructor.\n*\n* @private\n* @constructor\n* @returns {Notifier} notifier instance\n*\n* @example\n* var notifier = new Notifier();\n*/\nfunction Notifier() {\n\tif ( !(this instanceof Notifier) ) {\n\t\treturn new Notifier();\n\t}\n\treturn this;\n}\n\n/**\n* Notifies whether a new version is available.\n*\n* @private\n* @name notify\n* @memberof Notifier.prototype\n* @type {Function}\n*/\nsetReadOnly( Notifier.prototype, 'notify', noop );\n\n\n// EXPORTS //\n\nexport default Notifier;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* No operation.\n*\n* @example\n* noop();\n* // ...does nothing.\n*/\nfunction noop() {\n\t// Empty function...\n}\n\n\n// EXPORTS //\n\nexport default noop;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable stdlib/jsdoc-doctest, no-restricted-syntax */\n\n'use strict';\n\n// MODULES //\n\nvar parseArgs = require( 'minimist' ); // TODO: replace with stdlib equivalent\nimport format from '@stdlib/string/format';\nimport defaults from './defaults.json';\nimport isInteger from './is_integer.js';\nimport validate from './validate.js';\nimport proc from './process.js';\nimport log from './console.js';\nimport exitCode from './exit_code.js';\nimport notifier from './notifier.js';\n\n\n// VARIABLES //\n\n// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies. This should not be problematic as (1) this package is unlikely to be used outside of Node.js and, thus, in environments lacking support for the built-in APIs, and (2) most of the historical bugs for the respective APIs were in environments such as IE and not the versions of V8 included in Node.js >= v0.10.x.\nvar defineProperty = Object.defineProperty;\nvar objectKeys = Object.keys;\n\n\n// FUNCTIONS //\n\n/**\n* Defines a read-only non-enumerable property.\n*\n* @private\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {*} value - value to set\n*\n* @example\n* var obj = {};\n*\n* setReadOnly( obj, 'foo', 'bar' );\n*\n* try {\n* obj.foo = 'boop';\n* } catch ( err ) {\n* console.error( err.message );\n* }\n*/\nfunction setReadOnly( obj, prop, value ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': false,\n\t\t'writable': false,\n\t\t'value': value\n\t});\n}\n\n\n// MAIN //\n\n/**\n* Command-line interface constructor.\n*\n* @constructor\n* @param {Options} [options] - options\n* @param {Object} [options.pkg={}] - package meta information (package.json)\n* @param {string} [options.version] - command-line interface version\n* @param {string} [options.help=\"\"] - help text\n* @param {(string|boolean)} [options.title=true] - process title or a boolean indicating whether to set the process title\n* @param {boolean} [options.updates=true] - boolean indicating whether to check if a command-line interface is an outdated version\n* @param {Array} [options.argv] - command-line arguments\n* @param {Options} [options.options={}] - command-line interface options\n* @throws {TypeError} must provide an object\n* @throws {TypeError} must provide valid options\n* @returns {CLI} command-line interface\n*\n* @example\n* var opts = {\n* 'pkg': require( './path/to/package.json' ),\n* 'help': 'Usage: beep [options] ',\n* 'title': 'foo',\n* 'updates': true,\n* 'options': {\n* 'boolean': [\n* 'help',\n* 'version'\n* ]\n* }\n* };\n* var cli = new CLI( opts );\n* // returns \n*\n* cli.close();\n*/\nfunction CLI( options ) {\n\tvar nopts;\n\tvar flags;\n\tvar keys;\n\tvar opts;\n\tvar argv;\n\tvar args;\n\tvar self;\n\tvar err;\n\tif ( !( this instanceof CLI ) ) {\n\t\tif ( arguments.length ) {\n\t\t\treturn new CLI( options );\n\t\t}\n\t\treturn new CLI();\n\t}\n\topts = {\n\t\t'pkg': {},\n\t\t'help': defaults.help,\n\t\t'title': defaults.title,\n\t\t'version': defaults.version,\n\t\t'updates': defaults.updates,\n\t\t'argv': defaults.argv,\n\t\t'options': {}\n\t};\n\tif ( arguments.length ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tself = this;\n\n\t// Force the process to exit if an error is encountered when writing to `stdout` or `stderr`:\n\tproc.stdout.on( 'error', proc.exit );\n\tproc.stderr.on( 'error', proc.exit );\n\n\t/**\n\t* Returns parsed command-line arguments.\n\t*\n\t* @name args\n\t* @memberof CLI#\n\t* @type {Function}\n\t* @returns {StringArray} parsed command-line arguments\n\t*\n\t* @example\n\t* var cli = new CLI();\n\t*\n\t* var args = cli.args();\n\t* // returns \n\t*/\n\tsetReadOnly( this, 'args', getArgs );\n\n\t/**\n\t* Returns parsed command-line flags.\n\t*\n\t* @name flags\n\t* @memberof CLI#\n\t* @type {Function}\n\t* @returns {Object} parsed command-line flags\n\t*\n\t* @example\n\t* var cli = new CLI();\n\t*\n\t* var flags = cli.flags();\n\t* // returns \n\t*/\n\tsetReadOnly( this, 'flags', getFlags );\n\n\t/**\n\t* Prints usage information and exits the process.\n\t*\n\t* @name help\n\t* @memberof CLI#\n\t* @type {Function}\n\t*\n\t* @example\n\t* var opts = {\n\t* 'help': 'Usage: beep [options] '\n\t* };\n\t* var cli = new CLI( opts );\n\t*\n\t* cli.help();\n\t* // => 'Usage: beep [options] '\n\t*/\n\tsetReadOnly( this, 'help', help );\n\n\t/**\n\t* Prints the command-line interface version and exits the process.\n\t*\n\t* @name version\n\t* @memberof CLI#\n\t* @type {Function}\n\t*\n\t* @example\n\t* var opts = {\n\t* 'pkg': require( './path/to/package.json' )\n\t* };\n\t* var cli = new CLI( opts );\n\t*\n\t* cli.version();\n\t* // => '#.#.#'\n\t*/\n\tsetReadOnly( this, 'version', version );\n\n\t// Check whether to set the process title...\n\tif ( opts.title === true && opts.pkg ) {\n\t\tif ( typeof opts.pkg.bin === 'object' && opts.pkg.bin !== null ) {\n\t\t\tkeys = objectKeys( opts.pkg.bin );\n\n\t\t\t// Note: we don't have a way of knowing which command name in the `bin` hash was invoked; thus, we assume the first entry.\n\t\t\tproc.title = keys[ 0 ];\n\t\t} else if ( opts.pkg.name ) {\n\t\t\tproc.title = opts.pkg.name;\n\t\t}\n\t} else if ( opts.title ) {\n\t\tproc.title = opts.title;\n\t}\n\t// Check whether to notify the user of a new CLI version...\n\tif ( opts.updates && opts.pkg && opts.pkg.name && opts.pkg.version ) {\n\t\tnopts = {\n\t\t\t'pkg': opts.pkg\n\t\t};\n\t\tnotifier( nopts ).notify();\n\t}\n\t// Determine the command-line interface version...\n\tif ( !opts.version && opts.pkg && opts.pkg.version ) {\n\t\topts.version = opts.pkg.version;\n\t}\n\t// Parse command-line arguments:\n\tif ( opts.argv ) {\n\t\topts.argv = opts.argv.slice( 2 );\n\t} else {\n\t\topts.argv = proc.argv.slice( 2 );\n\t}\n\targv = parseArgs( opts.argv, opts.options );\n\n\t// Cache parsed arguments:\n\targs = argv._;\n\tdelete argv._;\n\tflags = argv;\n\n\t// Determine whether to print help text...\n\tif ( flags.help ) {\n\t\treturn this.help( 0 );\n\t}\n\t// Determine whether to print the version...\n\tif ( flags.version ) {\n\t\treturn this.version();\n\t}\n\treturn this;\n\n\t/**\n\t* Returns parsed command-line arguments.\n\t*\n\t* @private\n\t* @returns {StringArray} parsed command-line arguments\n\t*/\n\tfunction getArgs() {\n\t\treturn args.slice();\n\t}\n\n\t/**\n\t* Returns parsed command-line flags.\n\t*\n\t* @private\n\t* @returns {Object} parsed command-line flags\n\t*/\n\tfunction getFlags() {\n\t\tvar keys;\n\t\tvar o;\n\t\tvar k;\n\t\tvar i;\n\n\t\tkeys = objectKeys( flags );\n\t\to = {};\n\t\tfor ( i = 0; i < keys.length; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\to[ k ] = flags[ k ];\n\t\t}\n\t\treturn o;\n\t}\n\n\t/**\n\t* Prints usage information.\n\t*\n\t* ## Notes\n\t*\n\t* - Upon printing usage information, the function forces the process to exit.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} [code=0] - exit code\n\t*/\n\tfunction help( code ) {\n\t\tlog.error( opts.help );\n\t\tself.close( code || 0 );\n\t}\n\n\t/**\n\t* Prints the command-line interface version.\n\t*\n\t* ## Notes\n\t*\n\t* - Upon printing the version, the function forces the process to exit.\n\t*\n\t* @private\n\t*/\n\tfunction version() {\n\t\tlog.error( opts.version );\n\t\tself.close();\n\t}\n}\n\n/**\n* Gracefully exits the command-line interface and the calling process.\n*\n* @name close\n* @memberof CLI.prototype\n* @type {Function}\n* @param {NonNegativeInteger} [code=0] - exit code\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {void}\n*\n* @example\n* var cli = new CLI();\n*\n* // Gracefully exit:\n* cli.close();\n*/\nsetReadOnly( CLI.prototype, 'close', function close( code ) {\n\tif ( arguments.length === 0 ) {\n\t\texitCode( proc, 0 );\n\t\treturn;\n\t}\n\tif ( typeof code !== 'number' || !isInteger( code ) || code < 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', code ) );\n\t}\n\texitCode( proc, code );\n});\n\n/**\n* Exits the command-line interface and the calling process due to an error.\n*\n* ## Notes\n*\n* - The value assigned to the `message` property of the provided `Error` object is printed to `stderr` prior to exiting the command-line interface and the calling process.\n*\n* @name error\n* @memberof CLI.prototype\n* @type {Function}\n* @param {Error} error - error object\n* @param {NonNegativeInteger} [code=1] - exit code\n* @throws {TypeError} first argument must be an error object\n* @throws {TypeError} second argument must be a nonnegative integer\n* @returns {void}\n*\n* @example\n* var cli = new CLI();\n*\n* // ...\n*\n* // Create an error object:\n* var err = new Error( 'invalid operation' );\n*\n* // Exit the process:\n* cli.error( err, 0 );\n*/\nsetReadOnly( CLI.prototype, 'error', function onError( error, code ) {\n\tvar c;\n\tif ( !( error instanceof Error ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an error object. Value: `%s`.', error ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( typeof code !== 'number' || !isInteger( code ) || code < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%s`.', code ) );\n\t\t}\n\t\tc = code;\n\t} else {\n\t\tc = 1;\n\t}\n\tlog.error( 'Error: %s', error.message );\n\texitCode( proc, c );\n});\n\n/**\n* Forces the command-line interface (and the calling process) to exit.\n*\n* @name exit\n* @memberof CLI.prototype\n* @type {Function}\n* @param {NonNegativeInteger} [code=0] - exit code\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {void}\n*\n* @example\n* var cli = new CLI();\n*\n* // Forcefully exit:\n* cli.exit();\n*/\nsetReadOnly( CLI.prototype, 'exit', function exit( code ) {\n\tif ( arguments.length === 0 ) {\n\t\treturn proc.exit( 0 );\n\t}\n\tif ( typeof code !== 'number' || !isInteger( code ) || code < 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', code ) );\n\t}\n\tproc.exit( code );\n});\n\n\n// EXPORTS //\n\nexport default CLI;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 CLI\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/cli/ctor}\n*/\nimport CLI from './../ctor';\nsetReadOnly( ns, 'CLI', CLI );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a read-only property.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {*} value - value to set\n*\n* @example\n* var obj = {};\n*\n* setReadOnly( obj, 'foo', 'bar' );\n*\n* try {\n* obj.foo = 'boop';\n* } catch ( err ) {\n* console.error( err.message );\n* }\n*/\nfunction setReadOnly( obj, prop, value ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': value\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setReadOnly;\n"],"names":["main","Object","defineProperty","isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","f","digits","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","parseFloat","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply","objectProtoype","toStr","defineGetter","__defineGetter__","defineSetter","__defineSetter__","lookupGetter","__lookupGetter__","lookupSetter","__lookupSetter__","err","hasDefinePropertySupport","builtin","obj","prop","descriptor","hasValue","hasGet","hasSet","__proto__","get","set","defineProperty$2","x","test","isConstructorOrProto","key","isInteger","floor","hasOwnProp","hasOwnProperty","proc","log","console","NODE_VERSION","versions","node","exitCode","code","v","split","setTimeout","exit","Notifier","this","configurable","enumerable","writable","parseArgs","opts","bools","strings","unknownFn","unknown","boolean","allBools","concat","filter","Boolean","forEach","aliases","aliasIsBoolean","some","keys","alias","y","string","k","defaults","default","argv","_","setKey","o","undefined","Number","lastKey","setArg","val","argDefined","notFlags","next","m","letters","broken","stopEarly","objectKeys","setReadOnly","CLI","options","self","pkg","help","title","version","updates","validate","stdout","on","stderr","error","close","bin","name","notifier","notify","c","message","ns"],"mappings":";mOAsBA,IAAIA,EAA0C,mBAA1BC,OAAOC,eAAkCD,OAAOC,eAAiB,KCiCrF,IAAIA,EAAiBD,OAAOC,eCjB5B,SAASC,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAU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OACxB,MAAM,IAAIuC,UAAWiB,EAAQ,yEAA0EyG,IAExG,GAAKvH,UAAU1D,OAAS,EAAI,CAC3B,GAAqB,iBAATmH,IAAsBX,EAAWW,IAAUA,EAAO,EAC7D,MAAM,IAAI5D,UAAWiB,EAAQ,gFAAiF2C,IAE/GoE,EAAIpE,CACN,MACEoE,EAAI,EAEL1E,GAAIoE,MAAO,YAAaA,EAAMO,SAC9BtE,GAAUN,GAAM2E,EACjB,IAkBAnB,GAAaC,GAAIhK,UAAW,QAAQ,SAAe8G,GAClD,GAA0B,IAArBzD,UAAU1D,OACd,OAAO4G,GAAKW,KAAM,GAEnB,GAAqB,iBAATJ,IAAsBX,EAAWW,IAAUA,EAAO,EAC7D,MAAM,IAAI5D,UAAWiB,EAAQ,qEAAsE2C,IAEpGP,GAAKW,KAAMJ,EACZ,IC5XI,IAAAsE,GAAK,CAAG,SCSZ,SAAsB/F,EAAKC,EAAMtG,GAChCF,EAAgBuG,EAAKC,EAAM,CAC1B+B,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZvI,MAASA,GAEX,CDNA+K,CAAaqB,GAAI,MAAOpB","x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,18,23,26]} \ No newline at end of file diff --git a/ctor/README.md b/ctor/README.md deleted file mode 100644 index ffa50c1..0000000 --- a/ctor/README.md +++ /dev/null @@ -1,456 +0,0 @@ - - -# CLI - -> Command-line interface. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var CLI = require( '@stdlib/cli/ctor' ); -``` - -#### CLI( \[options] ) - -Command-line interface (CLI) constructor. - -```javascript -var cli = new CLI(); -// returns -``` - -The constructor accepts the following `options`: - -- **pkg**: package meta data, such as a `package.json` object. -- **version**: command-line interface version. Default: `pkg.version`. -- **title**: process title. If set to `true`, the default title is either `pkg.bin.` or `pkg.name`. If set to a `string`, the function sets the process title to the specified string. If set to `false`, the function does not set the process title. -- **help**: help text. Default: `''`. -- **updates**: `boolean` indicating whether to check if a more recent version of a command-line interface exists in the package registry. In order to check for updates, the function requires both `pkg.name` and `pkg.version` meta data. Default: `true`. -- **argv**: an `array` of command-line arguments. Default: `process.argv`. -- **options**: command-line argument parser options. - -To provide package meta data, such as the package `name` and `version`, set the `pkg` option. - -```javascript -var opts = { - 'pkg': require( './package.json' ) -}; - -var cli = new CLI( opts ); -// returns -``` - -To specify a particular command-line interface version (overriding package meta data), set the `version` option. - -```javascript -var opts = { - 'pkg': { - 'name': 'beep', - 'version': '1.1.1' - }, - 'version': '1.1.1-beta' -}; - -var cli = new CLI( opts ); -// returns - -cli.version(); -// => 1.1.1-beta -``` - -By default, an instance sets the process title to either the first key in `pkg.bin` or to `pkg.name`. To explicitly set the process title, set the `title` option. - -```javascript -var proc = require( 'process' ); - -var opts = { - 'title': 'beep-boop' -}; - -var cli = new CLI( opts ); -// returns - -console.log( proc.title ); -// => 'beep-boop' -``` - -To disable setting the process title, set the `title` option to `false`. - -```javascript -var opts = { - 'title': false -}; - -var cli = new CLI( opts ); -// returns -``` - -When the command-line flag `--help` is set, a command-line interface instance prints help text and exits the calling process. To specify the printed text, set the `help` option. - - - -```javascript -var opts = { - 'help': 'Usage: boop [options] ', - 'argv': [ - '/usr/local/bin/node', - 'foo.js', - '--help' - ] -}; - -var cli = new CLI( opts ); -// => Usage: boop [options] -``` - -By default, an instance resolves command-line arguments and flags via `process.argv`. To specify a custom set of command-line arguments, set the `argv` option. - -```javascript -var opts = { - 'argv': [ - '/usr/local/bin/node', - 'foo.js', - 'a', - 'b', - 'c' - ] -}; - -var cli = new CLI( opts ); - -var args = cli.args(); -// returns [ 'a', 'b', 'c' ] -``` - -To specify command-line argument parser options, such as command-line flag types and aliases, set the `options` option. - -```javascript -var opts = { - 'options': { - 'boolean': [ - 'help', - 'version' - ], - 'string': [ - 'output' - ], - 'alias': { - 'help': [ - 'h' - ], - 'version': [ - 'V' - ], - 'output': [ - 'o' - ] - } - }, - 'argv': [ - '/usr/local/bin/node', - 'foo.js', - '-o=bar.js' - ] -}; - -var cli = new CLI( opts ); - -var flags = cli.flags(); -/* returns - { - 'h': false, - 'help': false, - 'V': false, - 'version': false, - 'o': 'bar.js', - 'output': 'bar.js' - } -*/ -``` - -By default, if provided sufficient package meta data (package `name` and `version`), an instance checks whether a newer version of a command-line interface exists in the package registry. If a newer version exists, an instance writes a message to `stdout` indicating that a newer version exists. To disable this check, set the `updates` option to `false`. - -```javascript -var opts = { - 'updates': false -}; - -var cli = new CLI( opts ); -// returns -``` - -* * * - -### Prototype Methods - -#### CLI.prototype.close( \[code] ) - -Gracefully exits a command-line interface and the calling process. - -```javascript -var cli = new CLI(); - -// Gracefully exit: -cli.close(); -``` - -To specify an exit code, provide a `code` argument. - - - -```javascript -var cli = new CLI(); - -// Set the exit code to `1`: -cli.close( 1 ); -``` - -#### CLI.prototype.error( error\[, code] ) - -Prints an error message to `stderr` and exits a command-line interface and the calling process. - - - -```javascript -var cli = new CLI(); - -// ... - -// Create a new error object: -var err = new Error( 'invalid argument' ); - -// Exit due to the error: -cli.error( err ); -``` - -When exiting due to an error, the default exit code is `1`. To specify an alternative exit code, provide a `code` argument. - - - -```javascript -var cli = new CLI(); - -// ... - -// Create a new error object: -var err = new Error( 'invalid argument' ); - -// Exit due to the error: -cli.error( err, 2 ); -``` - -#### CLI.prototype.exit( \[code] ) - -Forcefully exits a command-line interface and the calling process. - -```javascript -var cli = new CLI(); - -// Forcefully exit: -cli.exit(); -``` - -To specify an exit code, provide a `code` argument. - - - -```javascript -var cli = new CLI(); - -// Set the exit code to `1`: -cli.exit( 1 ); -``` - -* * * - -### Instance Methods - -#### cli.args() - -Returns a list of command-line arguments. - -```javascript -var cli = new CLI({ - 'argv': [ - '/usr/local/bin/node', - 'foo.js', - 'a', - '--b', - 'c', - 'd' - ] -}); - -var args = cli.args(); -// returns [ 'a', 'd' ] -``` - -#### cli.flags() - -Returns command-line flags. - -```javascript -var cli = new CLI({ - 'argv': [ - '/usr/local/bin/node', - 'foo.js', - 'a', - '--b', - 'c', - '-def', - '--g=h', - 'i' - ] -}); - -var flags = cli.flags(); -// returns { 'b': 'c', 'd': true, 'e': true, 'f': true, 'g': 'h' } -``` - -#### cli.help( \[code] ) - -Prints help text to `stderr` and then exits the calling process. - -```javascript -var cli = new CLI({ - 'help': 'Usage: beep [options] ' -}); - -cli.help(); -// => Usage: beep [options] -``` - -By default, the process exits with an exit code equal to `0`. To exit with a different exit code, provide a `code` argument. - -#### cli.version() - -Prints the command-line interface version to `stderr` and then exits the calling process. - -```javascript -var cli = new CLI({ - 'version': '1.1.1' -}); - -cli.version(); -// => 1.1.1 -``` - -
- - - - - -* * * - -
- -## Notes - -- When either `--help` or `--version` command-line flag is set, a command-line interface instance prints the respective value and then exits the calling process. -- When explicitly setting `options.argv`, the first element is reserved for the absolute pathname of the executable which launched the calling process and the second element is reserved for the file path of the executed JavaScript file. - -
- - - - - -* * * - -
- -## Examples - - - - - -```javascript -var join = require( 'path' ).join; -var readFileSync = require( '@stdlib/fs/read-file' ).sync; -var CLI = require( '@stdlib/cli/ctor' ); -var main = require( './examples/fixtures/main.js' ); - -// Load help text: -var fopts = { - 'encoding': 'utf8' -}; -var help = readFileSync( join( __dirname, 'examples', 'fixtures', 'usage.txt' ), fopts ); - -// Set the command-line interface options: -var opts = { - 'pkg': require( './package.json' ), - 'options': require( './examples/fixtures/opts.json' ), - 'help': help, - 'title': true, - 'updates': true -}; - -// Create a new command-line interface: -var cli = new CLI( opts ); - -// Run main: -main( 'beep' ); - -// Close: -cli.close( 0 ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctor/benchmark/benchmark.js b/ctor/benchmark/benchmark.js deleted file mode 100644 index 0edb275..0000000 --- a/ctor/benchmark/benchmark.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var CLI = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var cli; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - cli = new CLI(); - if ( !( cli instanceof CLI ) ) { - b.fail( 'should return an instance' ); - } - } - b.toc(); - if ( !( cli instanceof CLI ) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new', function benchmark( b ) { - var ctor; - var cli; - var i; - - ctor = CLI; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - cli = ctor(); - if ( !( cli instanceof CLI ) ) { - b.fail( 'should return an instance' ); - } - } - b.toc(); - if ( !( cli instanceof CLI ) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,options', function benchmark( b ) { - var opts; - var cli; - var i; - - opts = { - 'pkg': { - 'name': 'beep', - 'version': '1.0.0' - }, - 'help': 'Usage: beep [options] ', - 'options': {}, - 'version': '1.0.0', - 'updates': true, - 'argv': [], - 'title': true - }; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - cli = new CLI( opts ); - if ( !( cli instanceof CLI ) ) { - b.fail( 'should return an instance' ); - } - } - b.toc(); - if ( !( cli instanceof CLI ) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':args', function benchmark( b ) { - var out; - var cli; - var i; - - cli = new CLI(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = cli.args(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':flags', function benchmark( b ) { - var out; - var cli; - var i; - - cli = new CLI(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = cli.flags(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/ctor/docs/types/index.d.ts b/ctor/docs/types/index.d.ts deleted file mode 100644 index f55df2d..0000000 --- a/ctor/docs/types/index.d.ts +++ /dev/null @@ -1,209 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Package meta information (package.json) (default: {}). - */ - pkg?: any; - - /** - * Command-line interface version. - */ - version?: string; - - /** - * Help text (default: ''). - */ - help?: string; - - /** - * Process title or a boolean indicating whether to set the process title (default: true). - */ - title?: string | boolean; - - /** - * Boolean indicating whether to check if a command-line interface is an outdated version (default: true). - */ - updates?: boolean; - - /** - * Command-line arguments. - */ - argv?: Array; - - /** - * Command-line interface options (default: {}). - */ - options?: Options; -} - -/** -* Command-line interface. -*/ -declare class CLI { - /** - * Command-line interface constructor. - * - * @param options - options - * @param options.pkg - package meta information (package.json) (default: {}) - * @param options.version - command-line interface version - * @param options.help - help text (default: '') - * @param options.title - process title or a boolean indicating whether to set the process title (default: true) - * @param options.updates - boolean indicating whether to check if a command-line interface is an outdated version (default: true) - * @param options.argv - command-line arguments - * @param options.options - command-line interface options (default: {}) - * @throws must provide valid options - * @returns command-line interface - * - * @example - * var opts = { - * 'pkg': require( './path/to/package.json' ), - * 'help': 'Usage: beep [options] ', - * 'title': 'foo', - * 'updates': true, - * 'options': { - * 'boolean': [ - * 'help', - * 'version' - * ] - * } - * }; - * var cli = new CLI( opts ); - * // returns - * - * cli.close(); - */ - constructor( options?: Options ); - - /** - * Returns parsed command-line arguments. - * - * @returns parsed command-line arguments - * - * @example - * var cli = new CLI(); - * - * var args = cli.args(); - * // returns - */ - args(): Array; - - /** - * Returns parsed command-line arguments. - * - * @returns parsed command-line arguments - * - * @example - * var cli = new CLI(); - * - * var args = cli.args(); - * // returns - */ - flags(): Array; - - /** - * Prints usage information and exits the process. - * - * @example - * var opts = { - * 'help': 'Usage: beep [options] ' - * }; - * var cli = new CLI( opts ); - * - * cli.help(); - * // => 'Usage: beep [options] ' - */ - help(): void; - - /** - * Prints the command-line interface version and exits the process. - * - * @example - * var opts = { - * 'pkg': require( './path/to/package.json' ) - * }; - * var cli = new CLI( opts ); - * - * cli.version(); - * // => '#.#.#' - */ - version(): void; - - /** - * Gracefully exits the command-line interface and the calling process. - * - * @param code - exit code (default: 0) - * @throws must provide a nonnegative integer - * - * @example - * var cli = new CLI(); - * - * // Gracefully exit: - * cli.close(); - */ - close( code?: number ): void; - - /** - * Exits the command-line interface and the calling process due to an error. - * - * ## Notes - * - * - The value assigned to the `message` property of the provided `Error` object is printed to `stderr` prior to exiting the command-line interface and the calling process. - * - * @param error - error object - * @param code - exit code (default: 1) - * @throws second argument must be a nonnegative integer - * - * @example - * var cli = new CLI(); - * - * // ... - * - * // Create an error object: - * var err = new Error( 'invalid operation' ); - * - * // Exit the process: - * cli.error( err, 0 ); - */ - error( error: Error, code?: number ): void; - - /** - * Forces the command-line interface (and the calling process) to exit. - * - * @param code - exit code (default: 0) - * @throws must provide a nonnegative integer - * - * @example - * var cli = new CLI(); - * - * // Forcefully exit: - * cli.exit(); - */ - exit( code?: number ): void; -} - - -// EXPORTS // - -export = CLI; diff --git a/ctor/docs/types/test.ts b/ctor/docs/types/test.ts deleted file mode 100644 index bae543e..0000000 --- a/ctor/docs/types/test.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CLI = require( './index' ); - - -// TESTS // - -// The function returns a command-line interface... -{ - new CLI(); // $ExpectType CLI - new CLI( { 'updates': false } ); // $ExpectType CLI -} - -// The compiler throws an error if the constructor function is provided an argument that is not an options object... -{ - new CLI( 123 ); // $ExpectError - new CLI( 'abc' ); // $ExpectError - new CLI( null ); // $ExpectError - new CLI( true ); // $ExpectError - new CLI( false ); // $ExpectError - new CLI( [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `version` option which is not a string... -{ - new CLI( { 'version': 123 } ); // $ExpectError - new CLI( { 'version': true } ); // $ExpectError - new CLI( { 'version': false } ); // $ExpectError - new CLI( { 'version': null } ); // $ExpectError - new CLI( { 'version': [] } ); // $ExpectError - new CLI( { 'version': {} } ); // $ExpectError - new CLI( { 'version': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `help` option which is not a string... -{ - new CLI( { 'help': 123 } ); // $ExpectError - new CLI( { 'help': true } ); // $ExpectError - new CLI( { 'help': false } ); // $ExpectError - new CLI( { 'help': null } ); // $ExpectError - new CLI( { 'help': [] } ); // $ExpectError - new CLI( { 'help': {} } ); // $ExpectError - new CLI( { 'help': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `title` option which is neither a string nor boolean... -{ - new CLI( { 'title': 123 } ); // $ExpectError - new CLI( { 'title': null } ); // $ExpectError - new CLI( { 'title': [] } ); // $ExpectError - new CLI( { 'title': {} } ); // $ExpectError - new CLI( { 'title': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `updates` option which is not a boolean... -{ - new CLI( { 'updates': 123 } ); // $ExpectError - new CLI( { 'updates': 'abc' } ); // $ExpectError - new CLI( { 'updates': null } ); // $ExpectError - new CLI( { 'updates': [] } ); // $ExpectError - new CLI( { 'updates': {} } ); // $ExpectError - new CLI( { 'updates': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `argv` option which is not an array... -{ - new CLI( { 'argv': 'abc' } ); // $ExpectError - new CLI( { 'argv': 123 } ); // $ExpectError - new CLI( { 'argv': true } ); // $ExpectError - new CLI( { 'argv': false } ); // $ExpectError - new CLI( { 'argv': null } ); // $ExpectError - new CLI( { 'argv': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `options` option which is not an options object... -{ - new CLI( { 'options': 'abc' } ); // $ExpectError - new CLI( { 'options': 123 } ); // $ExpectError - new CLI( { 'options': true } ); // $ExpectError - new CLI( { 'options': false } ); // $ExpectError - new CLI( { 'options': null } ); // $ExpectError - new CLI( { 'options': [] } ); // $ExpectError - new CLI( { 'options': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the constructor function is provided more than one argument... -{ - new CLI( {}, {} ); // $ExpectError - new CLI( {}, {}, {} ); // $ExpectError -} diff --git a/ctor/examples/fixtures/main.js b/ctor/examples/fixtures/main.js deleted file mode 100644 index d730e8a..0000000 --- a/ctor/examples/fixtures/main.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Prints to `stdout`. -* -* @private -* @param {string} str - string to print -*/ -function stdout( str ) { - console.log( str ); // eslint-disable-line no-console -} - - -// EXPORTS // - -module.exports = stdout; diff --git a/ctor/examples/fixtures/opts.json b/ctor/examples/fixtures/opts.json deleted file mode 100644 index 60597f3..0000000 --- a/ctor/examples/fixtures/opts.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "boolean": [ - "help", - "version" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ] - } -} diff --git a/ctor/examples/fixtures/usage.txt b/ctor/examples/fixtures/usage.txt deleted file mode 100644 index 779f509..0000000 --- a/ctor/examples/fixtures/usage.txt +++ /dev/null @@ -1,8 +0,0 @@ - -Usage: demo [options] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - diff --git a/ctor/examples/index.js b/ctor/examples/index.js deleted file mode 100644 index 0ed773f..0000000 --- a/ctor/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var join = require( 'path' ).join; -var readFileSync = require( '@stdlib/fs/read-file' ).sync; -var CLI = require( './../lib' ); -var main = require( './fixtures/main.js' ); - -// Load help text: -var fopts = { - 'encoding': 'utf8' -}; -var help = readFileSync( join( __dirname, 'fixtures', 'usage.txt' ), fopts ); - -// Set the command-line interface options: -var opts = { - 'pkg': require( './../package.json' ), - 'options': require( './fixtures/opts.json' ), - 'help': help, - 'title': true, - 'updates': true -}; - -// Create a new command-line interface: -var cli = new CLI( opts ); - -// Run main: -main( 'beep' ); - -// Close: -cli.close( 0 ); diff --git a/ctor/lib/console.js b/ctor/lib/console.js deleted file mode 100644 index 3a2e2de..0000000 --- a/ctor/lib/console.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = console; diff --git a/ctor/lib/defaults.json b/ctor/lib/defaults.json deleted file mode 100644 index 938bf3f..0000000 --- a/ctor/lib/defaults.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "pkg": {}, - "help": "", - "title": true, - "version": "", - "updates": true, - "argv": null, - "options": {} -} diff --git a/ctor/lib/exit_code.js b/ctor/lib/exit_code.js deleted file mode 100644 index 0e8dacd..0000000 --- a/ctor/lib/exit_code.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var proc = require( './process.js' ); - - -// VARIABLES // - -var NODE_VERSION = proc.versions.node; -var TIMEOUT = 10; // ms - - -// MAIN // - -/** -* Sets the process exit code. -* -* @private -* @param {Object} proc - process object -* @param {NonNegativeInteger} code - exit code -* @returns {void} -*/ -function exitCode( proc, code ) { - var v; - - // Handle old Node.js versions lacking `process.exitCode` support... - v = NODE_VERSION.split( '.' ); - v[ 0 ] = parseInt( v[ 0 ], 10 ); - v[ 1 ] = parseInt( v[ 1 ], 10 ); - - // Case: >0.x.x - if ( v[ 0 ] > 0 ) { - proc.exitCode = code; - return; - } - // Case: >0.10.x - if ( v[ 1 ] > 10 ) { - proc.exitCode = code; - return; - } - // Case: <= 0.10.x - proc.exitCode = code; // NOTE: assigning this property should have no operational effect in older Node.js versions - - // No choice but to forcefully exit during a subsequent turn of the event loop (note: the timeout duration is arbitrary; the main idea is to hopefully allow the event loop queue to drain before exiting the process, including the flushing of stdio streams which can be non-blocking/asynchronous)... - setTimeout( onTimeout, TIMEOUT ); - - /** - * Callback invoked during a subsequent turn of the event loop. - * - * @private - */ - function onTimeout() { - proc.exit( code ); - } -} - - -// EXPORTS // - -module.exports = exitCode; diff --git a/ctor/lib/index.js b/ctor/lib/index.js deleted file mode 100644 index bc66e95..0000000 --- a/ctor/lib/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Command-line interface (CLI). -* -* @module @stdlib/cli/ctor -* -* @example -* var CLI = require( '@stdlib/cli/ctor' ); -* -* var opts = { -* 'help': 'Usage: beep [options] ', -* 'title': 'foo', -* 'updates': true, -* 'options': { -* 'boolean': [ -* 'help', -* 'version' -* ] -* } -* }; -* var cli = new CLI( opts ); -* // returns -* -* cli.close(); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctor/lib/is_integer.js b/ctor/lib/is_integer.js deleted file mode 100644 index 3b60d85..0000000 --- a/ctor/lib/is_integer.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Tests if a finite double-precision floating-point number is an integer. -* -* @private -* @param {number} x - value to test -* @returns {boolean} boolean indicating whether the value is an integer -* -* @example -* var bool = isInteger( 1.0 ); -* // returns true -* -* @example -* var bool = isInteger( 3.14 ); -* // returns false -*/ -function isInteger( x ) { - // NOTE: we explicitly avoid using `@stdlib/math/base/special` here in order to avoid circular dependencies. - return ( Math.floor( x ) === x ); // eslint-disable-line stdlib/no-builtin-math -} - - -// EXPORTS // - -module.exports = isInteger; diff --git a/ctor/lib/main.js b/ctor/lib/main.js deleted file mode 100644 index 881d710..0000000 --- a/ctor/lib/main.js +++ /dev/null @@ -1,422 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 stdlib/jsdoc-doctest, no-restricted-syntax */ - -'use strict'; - -// MODULES // - -var parseArgs = require( 'minimist' ); // TODO: replace with stdlib equivalent -var format = require( '@stdlib/string/format' ); -var defaults = require( './defaults.json' ); -var isInteger = require( './is_integer.js' ); -var validate = require( './validate.js' ); -var proc = require( './process.js' ); -var log = require( './console.js' ); -var exitCode = require( './exit_code.js' ); -var notifier = require( './notifier.js' ); - - -// VARIABLES // - -// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies. This should not be problematic as (1) this package is unlikely to be used outside of Node.js and, thus, in environments lacking support for the built-in APIs, and (2) most of the historical bugs for the respective APIs were in environments such as IE and not the versions of V8 included in Node.js >= v0.10.x. -var defineProperty = Object.defineProperty; -var objectKeys = Object.keys; - - -// FUNCTIONS // - -/** -* Defines a read-only non-enumerable property. -* -* @private -* @param {Object} obj - object on which to define the property -* @param {(string|symbol)} prop - property name -* @param {*} value - value to set -* -* @example -* var obj = {}; -* -* setReadOnly( obj, 'foo', 'bar' ); -* -* try { -* obj.foo = 'boop'; -* } catch ( err ) { -* console.error( err.message ); -* } -*/ -function setReadOnly( obj, prop, value ) { - defineProperty( obj, prop, { - 'configurable': false, - 'enumerable': false, - 'writable': false, - 'value': value - }); -} - - -// MAIN // - -/** -* Command-line interface constructor. -* -* @constructor -* @param {Options} [options] - options -* @param {Object} [options.pkg={}] - package meta information (package.json) -* @param {string} [options.version] - command-line interface version -* @param {string} [options.help=""] - help text -* @param {(string|boolean)} [options.title=true] - process title or a boolean indicating whether to set the process title -* @param {boolean} [options.updates=true] - boolean indicating whether to check if a command-line interface is an outdated version -* @param {Array} [options.argv] - command-line arguments -* @param {Options} [options.options={}] - command-line interface options -* @throws {TypeError} must provide an object -* @throws {TypeError} must provide valid options -* @returns {CLI} command-line interface -* -* @example -* var opts = { -* 'pkg': require( './path/to/package.json' ), -* 'help': 'Usage: beep [options] ', -* 'title': 'foo', -* 'updates': true, -* 'options': { -* 'boolean': [ -* 'help', -* 'version' -* ] -* } -* }; -* var cli = new CLI( opts ); -* // returns -* -* cli.close(); -*/ -function CLI( options ) { - var nopts; - var flags; - var keys; - var opts; - var argv; - var args; - var self; - var err; - if ( !( this instanceof CLI ) ) { - if ( arguments.length ) { - return new CLI( options ); - } - return new CLI(); - } - opts = { - 'pkg': {}, - 'help': defaults.help, - 'title': defaults.title, - 'version': defaults.version, - 'updates': defaults.updates, - 'argv': defaults.argv, - 'options': {} - }; - if ( arguments.length ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - self = this; - - // Force the process to exit if an error is encountered when writing to `stdout` or `stderr`: - proc.stdout.on( 'error', proc.exit ); - proc.stderr.on( 'error', proc.exit ); - - /** - * Returns parsed command-line arguments. - * - * @name args - * @memberof CLI# - * @type {Function} - * @returns {StringArray} parsed command-line arguments - * - * @example - * var cli = new CLI(); - * - * var args = cli.args(); - * // returns - */ - setReadOnly( this, 'args', getArgs ); - - /** - * Returns parsed command-line flags. - * - * @name flags - * @memberof CLI# - * @type {Function} - * @returns {Object} parsed command-line flags - * - * @example - * var cli = new CLI(); - * - * var flags = cli.flags(); - * // returns - */ - setReadOnly( this, 'flags', getFlags ); - - /** - * Prints usage information and exits the process. - * - * @name help - * @memberof CLI# - * @type {Function} - * - * @example - * var opts = { - * 'help': 'Usage: beep [options] ' - * }; - * var cli = new CLI( opts ); - * - * cli.help(); - * // => 'Usage: beep [options] ' - */ - setReadOnly( this, 'help', help ); - - /** - * Prints the command-line interface version and exits the process. - * - * @name version - * @memberof CLI# - * @type {Function} - * - * @example - * var opts = { - * 'pkg': require( './path/to/package.json' ) - * }; - * var cli = new CLI( opts ); - * - * cli.version(); - * // => '#.#.#' - */ - setReadOnly( this, 'version', version ); - - // Check whether to set the process title... - if ( opts.title === true && opts.pkg ) { - if ( typeof opts.pkg.bin === 'object' && opts.pkg.bin !== null ) { - keys = objectKeys( opts.pkg.bin ); - - // Note: we don't have a way of knowing which command name in the `bin` hash was invoked; thus, we assume the first entry. - proc.title = keys[ 0 ]; - } else if ( opts.pkg.name ) { - proc.title = opts.pkg.name; - } - } else if ( opts.title ) { - proc.title = opts.title; - } - // Check whether to notify the user of a new CLI version... - if ( opts.updates && opts.pkg && opts.pkg.name && opts.pkg.version ) { - nopts = { - 'pkg': opts.pkg - }; - notifier( nopts ).notify(); - } - // Determine the command-line interface version... - if ( !opts.version && opts.pkg && opts.pkg.version ) { - opts.version = opts.pkg.version; - } - // Parse command-line arguments: - if ( opts.argv ) { - opts.argv = opts.argv.slice( 2 ); - } else { - opts.argv = proc.argv.slice( 2 ); - } - argv = parseArgs( opts.argv, opts.options ); - - // Cache parsed arguments: - args = argv._; - delete argv._; - flags = argv; - - // Determine whether to print help text... - if ( flags.help ) { - return this.help( 0 ); - } - // Determine whether to print the version... - if ( flags.version ) { - return this.version(); - } - return this; - - /** - * Returns parsed command-line arguments. - * - * @private - * @returns {StringArray} parsed command-line arguments - */ - function getArgs() { - return args.slice(); - } - - /** - * Returns parsed command-line flags. - * - * @private - * @returns {Object} parsed command-line flags - */ - function getFlags() { - var keys; - var o; - var k; - var i; - - keys = objectKeys( flags ); - o = {}; - for ( i = 0; i < keys.length; i++ ) { - k = keys[ i ]; - o[ k ] = flags[ k ]; - } - return o; - } - - /** - * Prints usage information. - * - * ## Notes - * - * - Upon printing usage information, the function forces the process to exit. - * - * @private - * @param {NonNegativeInteger} [code=0] - exit code - */ - function help( code ) { - log.error( opts.help ); - self.close( code || 0 ); - } - - /** - * Prints the command-line interface version. - * - * ## Notes - * - * - Upon printing the version, the function forces the process to exit. - * - * @private - */ - function version() { - log.error( opts.version ); - self.close(); - } -} - -/** -* Gracefully exits the command-line interface and the calling process. -* -* @name close -* @memberof CLI.prototype -* @type {Function} -* @param {NonNegativeInteger} [code=0] - exit code -* @throws {TypeError} must provide a nonnegative integer -* @returns {void} -* -* @example -* var cli = new CLI(); -* -* // Gracefully exit: -* cli.close(); -*/ -setReadOnly( CLI.prototype, 'close', function close( code ) { - if ( arguments.length === 0 ) { - exitCode( proc, 0 ); - return; - } - if ( typeof code !== 'number' || !isInteger( code ) || code < 0 ) { - throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', code ) ); - } - exitCode( proc, code ); -}); - -/** -* Exits the command-line interface and the calling process due to an error. -* -* ## Notes -* -* - The value assigned to the `message` property of the provided `Error` object is printed to `stderr` prior to exiting the command-line interface and the calling process. -* -* @name error -* @memberof CLI.prototype -* @type {Function} -* @param {Error} error - error object -* @param {NonNegativeInteger} [code=1] - exit code -* @throws {TypeError} first argument must be an error object -* @throws {TypeError} second argument must be a nonnegative integer -* @returns {void} -* -* @example -* var cli = new CLI(); -* -* // ... -* -* // Create an error object: -* var err = new Error( 'invalid operation' ); -* -* // Exit the process: -* cli.error( err, 0 ); -*/ -setReadOnly( CLI.prototype, 'error', function onError( error, code ) { - var c; - if ( !( error instanceof Error ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an error object. Value: `%s`.', error ) ); - } - if ( arguments.length > 1 ) { - if ( typeof code !== 'number' || !isInteger( code ) || code < 0 ) { - throw new TypeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%s`.', code ) ); - } - c = code; - } else { - c = 1; - } - log.error( 'Error: %s', error.message ); - exitCode( proc, c ); -}); - -/** -* Forces the command-line interface (and the calling process) to exit. -* -* @name exit -* @memberof CLI.prototype -* @type {Function} -* @param {NonNegativeInteger} [code=0] - exit code -* @throws {TypeError} must provide a nonnegative integer -* @returns {void} -* -* @example -* var cli = new CLI(); -* -* // Forcefully exit: -* cli.exit(); -*/ -setReadOnly( CLI.prototype, 'exit', function exit( code ) { - if ( arguments.length === 0 ) { - return proc.exit( 0 ); - } - if ( typeof code !== 'number' || !isInteger( code ) || code < 0 ) { - throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', code ) ); - } - proc.exit( code ); -}); - - -// EXPORTS // - -module.exports = CLI; diff --git a/ctor/lib/notifier.js b/ctor/lib/notifier.js deleted file mode 100644 index 63e74f8..0000000 --- a/ctor/lib/notifier.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// FIXME: remove this stub and create a stdlib equivalent of update-notifier - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var noop = require( '@stdlib/utils/noop' ); - - -// MAIN // - -/** -* Notifier constructor. -* -* @private -* @constructor -* @returns {Notifier} notifier instance -* -* @example -* var notifier = new Notifier(); -*/ -function Notifier() { - if ( !(this instanceof Notifier) ) { - return new Notifier(); - } - return this; -} - -/** -* Notifies whether a new version is available. -* -* @private -* @name notify -* @memberof Notifier.prototype -* @type {Function} -*/ -setReadOnly( Notifier.prototype, 'notify', noop ); - - -// EXPORTS // - -module.exports = Notifier; diff --git a/ctor/lib/process.js b/ctor/lib/process.js deleted file mode 100644 index d940eb6..0000000 --- a/ctor/lib/process.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var proc = require( 'process' ); - - -// EXPORTS // - -module.exports = proc; diff --git a/ctor/lib/validate.js b/ctor/lib/validate.js deleted file mode 100644 index 081806c..0000000 --- a/ctor/lib/validate.js +++ /dev/null @@ -1,115 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var hasOwnProp = Object.prototype.hasOwnProperty; -var isArray = Array.isArray; - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {Object} [options.pkg] - package meta information (package.json) -* @param {string} [options.version] - command-line interface version -* @param {string} [options.help] - help text -* @param {(string|boolean)} [options.title] - process title or a boolean indicating whether to set the process title -* @param {boolean} [options.updates] - boolean indicating whether to check if a command-line interface is an outdated version -* @param {Array} [options.argv] - command-line arguments -* @param {Options} [options.options] - command-line interface options -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'pkg': {}, -* 'version': '1.0.0', -* 'help': 'Usage: beep [options] ', -* 'title': 'foo', -* 'updates': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( typeof options !== 'object' || options === null || isArray( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp.call( options, 'pkg' ) ) { - opts.pkg = options.pkg; - if ( typeof opts.pkg !== 'object' || opts.pkg === null || isArray( opts.pkg ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an object. Option: `%s`.', 'pkg', opts.pkg ) ); - } - } - if ( hasOwnProp.call( options, 'help' ) ) { - opts.help = options.help; - if ( typeof opts.help !== 'string' ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'help', opts.help ) ); - } - } - if ( hasOwnProp.call( options, 'version' ) ) { - opts.version = options.version; - if ( typeof opts.version !== 'string' ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'version', opts.version ) ); - } - } - if ( hasOwnProp.call( options, 'title' ) ) { - opts.title = options.title; - if ( typeof opts.title !== 'string' && typeof opts.title !== 'boolean' ) { - return new TypeError( format( 'invalid option. `%s` option must be either a string or boolean primitive. Option: `%s`.', 'title', opts.title ) ); - } - } - if ( hasOwnProp.call( options, 'updates' ) ) { - opts.updates = options.updates; - if ( typeof opts.updates !== 'boolean' ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'updates', opts.updates ) ); - } - } - if ( hasOwnProp.call( options, 'argv' ) ) { - opts.argv = options.argv; - if ( !isArray( opts.argv ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array. Option: `%s`.', 'argv', opts.argv ) ); - } - } - if ( hasOwnProp.call( options, 'options' ) ) { - opts.options = options.options; - if ( typeof opts.options !== 'object' || opts.options === null || isArray( opts.options ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a plain object. Option: `%s`.', 'options', opts.options ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/ctor/package.json b/ctor/package.json deleted file mode 100644 index 87ec629..0000000 --- a/ctor/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/cli/ctor", - "version": "0.0.0", - "description": "Command-line interface.", - "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", - "browser": { - "process": "process/" - }, - "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", - "utilities", - "utility", - "utils", - "util", - "cli", - "command-line", - "interface" - ], - "__stdlib__": { - "envs": { - "browser": false - } - } -} diff --git a/ctor/test/fixtures/stderr.js b/ctor/test/fixtures/stderr.js deleted file mode 100644 index f1523db..0000000 --- a/ctor/test/fixtures/stderr.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Writable = require( 'stream' ).Writable; - - -// MAIN // - -/** -* Writable stream. -* -* @private -* @constructor -* @returns {Stream} Stream instance -*/ -function Stream() { - if ( !(this instanceof Stream) ) { - return new Stream(); - } - Writable.call( this ); - return this; -} - -// Create a prototype which inherits from the parent prototype: -Stream.prototype = Object.create( Writable.prototype ); - -// Set the constructor: -Stream.prototype.constructor = Stream; - -/** -* Implements the `_write` method. -* -* @private -*/ -Stream.prototype._write = function _write() { // eslint-disable-line no-underscore-dangle - // noop -}; - - -// EXPORTS // - -module.exports = Stream; diff --git a/ctor/test/fixtures/stdout.js b/ctor/test/fixtures/stdout.js deleted file mode 100644 index f1523db..0000000 --- a/ctor/test/fixtures/stdout.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Writable = require( 'stream' ).Writable; - - -// MAIN // - -/** -* Writable stream. -* -* @private -* @constructor -* @returns {Stream} Stream instance -*/ -function Stream() { - if ( !(this instanceof Stream) ) { - return new Stream(); - } - Writable.call( this ); - return this; -} - -// Create a prototype which inherits from the parent prototype: -Stream.prototype = Object.create( Writable.prototype ); - -// Set the constructor: -Stream.prototype.constructor = Stream; - -/** -* Implements the `_write` method. -* -* @private -*/ -Stream.prototype._write = function _write() { // eslint-disable-line no-underscore-dangle - // noop -}; - - -// EXPORTS // - -module.exports = Stream; diff --git a/ctor/test/fixtures/usage.txt b/ctor/test/fixtures/usage.txt deleted file mode 100644 index 779f509..0000000 --- a/ctor/test/fixtures/usage.txt +++ /dev/null @@ -1,8 +0,0 @@ - -Usage: demo [options] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - diff --git a/ctor/test/test.exit_code.js b/ctor/test/test.exit_code.js deleted file mode 100644 index d49cfb1..0000000 --- a/ctor/test/test.exit_code.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var exitCode = require( './../lib/exit_code.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof exitCode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function sets the process exit code (Node.js versions >0.x.x)', function test( t ) { - var exitCode; - var proc; - var mock; - - mock = { - 'versions': { - 'node': '1.0.0' - } - }; - - exitCode = proxyquire( './../lib/exit_code.js', { - './process.js': mock - }); - - proc = { - 'exit': exit, - 'exitCode': -1 - }; - - exitCode( proc, 1 ); - - t.strictEqual( proc.exitCode, 1, 'returns expected value' ); - t.end(); - - function exit() { - t.fail( 'should not be called' ); - } -}); - -tape( 'the function sets the process exit code (Node.js versions >0.10.x)', function test( t ) { - var exitCode; - var proc; - var mock; - - mock = { - 'versions': { - 'node': '0.11.0' - } - }; - - exitCode = proxyquire( './../lib/exit_code.js', { - './process.js': mock - }); - - proc = { - 'exit': exit, - 'exitCode': -1 - }; - - exitCode( proc, 1 ); - - t.strictEqual( proc.exitCode, 1, 'returns expected value' ); - t.end(); - - function exit() { - t.fail( 'should not be called' ); - } -}); - -tape( 'the function sets the process "exit code" and forcefully exits the calling process on older Node.js versions (Node.js versions <=0.10.x)', function test( t ) { - var exitCode; - var proc; - var mock; - - mock = { - 'versions': { - 'node': '0.10.9999999' - } - }; - - exitCode = proxyquire( './../lib/exit_code.js', { - './process.js': mock - }); - - proc = { - 'exit': exit, - 'exitCode': -1 - }; - - exitCode( proc, 1 ); - - t.strictEqual( proc.exitCode, 1, 'returns expected value' ); - - function exit( code ) { - t.ok( true, 'forcefully exits' ); - t.strictEqual( code, 1, 'sets exit code' ); - t.end(); - } -}); diff --git a/ctor/test/test.js b/ctor/test/test.js deleted file mode 100644 index 76ce280..0000000 --- a/ctor/test/test.js +++ /dev/null @@ -1,1468 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var join = require( 'path' ).join; -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var IS_BROWSER = require( '@stdlib/assert/is-browser' ); -var readFileSync = require( '@stdlib/fs/read-file' ).sync; -var instanceOf = require( '@stdlib/assert/instance-of' ); -var noop = require( '@stdlib/utils/noop' ); -var CLI = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': IS_BROWSER -}; - - -// FIXTURES // - -var stdout = require( './fixtures/stdout.js' ); -var stderr = require( './fixtures/stderr.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof CLI, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - t.strictEqual( instanceOf( new CLI(), CLI ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var cli; - - ctor = CLI; - cli = ctor(); - - t.strictEqual( instanceOf( cli, CLI ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided an `options` argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var cli = new CLI( value ); - return cli; - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var cli = new CLI({ - 'pkg': value - }); - return cli; - }; - } -}); - -tape( 'the returned instance exits the process if an error is encountered when writing to `stdout`', function test( t ) { - var stream; - var ctor; - var proc; - - stream = stdout(); - proc = { - 'exit': exit, - 'stdout': stream, - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - ctor(); - stream.emit( 'error' ); - - function exit() { - t.ok( true, 'exits the process' ); - t.end(); - } -}); - -tape( 'the returned instance exits the process if an error is encountered when writing to `stderr`', function test( t ) { - var stream; - var ctor; - var proc; - - stream = stderr(); - proc = { - 'exit': exit, - 'stdout': stdout(), - 'stderr': stream - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - ctor(); - stream.emit( 'error' ); - - function exit() { - t.ok( true, 'exits the process' ); - t.end(); - } -}); - -tape( 'if the `title` option is `true`, the returned instance sets the process title (bin object)', function test( t ) { - var ctor; - var proc; - var opts; - - proc = { - 'exit': noop, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'title': true, - 'pkg': { - 'name': 'beep', - 'version': '0.0.0', - 'bin': { - 'demo': './bin/cli' - } - } - }; - ctor( opts ); - - t.strictEqual( proc.title, 'demo', 'sets the process title' ); - t.end(); -}); - -tape( 'if the `title` option is `true`, the returned instance sets the process title (bin string)', function test( t ) { - var ctor; - var proc; - var opts; - - proc = { - 'exit': noop, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'title': true, - 'pkg': { - 'name': 'beep', - 'version': '0.0.0', - 'bin': './bin/cli' - } - }; - ctor( opts ); - - t.strictEqual( proc.title, 'beep', 'sets the process title' ); - t.end(); -}); - -tape( 'if the `title` option is `true`, the returned instance sets the process title (no bin)', function test( t ) { - var ctor; - var proc; - var opts; - - proc = { - 'exit': noop, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'title': true, - 'pkg': { - 'name': 'beep', - 'version': '0.0.0' - } - }; - ctor( opts ); - - t.strictEqual( proc.title, 'beep', 'sets the process title' ); - t.end(); -}); - -tape( 'if the `title` option is `true` and insufficient package meta information is provided, the returned instance does not set the process title', function test( t ) { - var ctor; - var proc; - var opts; - - proc = { - 'exit': noop, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'title': true, - 'pkg': {} - }; - ctor( opts ); - - t.strictEqual( proc.title, '', 'does not set the process title' ); - t.end(); -}); - -tape( 'if the `title` option is a string, the returned instance sets the process title to the specified string', function test( t ) { - var ctor; - var proc; - var opts; - - proc = { - 'exit': noop, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'title': 'boop', - 'pkg': { - 'name': 'beep', - 'version': '0.0.0' - } - }; - ctor( opts ); - - t.strictEqual( proc.title, 'boop', 'sets the process title' ); - t.end(); -}); - -tape( 'if the `title` option is `false`, the returned instance does not set the process title', function test( t ) { - var ctor; - var proc; - var opts; - - proc = { - 'exit': noop, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'title': false, - 'pkg': { - 'name': 'beep', - 'version': '0.0.0' - } - }; - ctor( opts ); - - t.strictEqual( proc.title, '', 'does not set the process title' ); - t.end(); -}); - -tape( 'if the `updates` option is `true` and package meta data is provided, the returned instance checks for available updates in the package registry', function test( t ) { - var ctor; - var proc; - var opts; - - proc = { - 'exit': noop, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc, - './notifier.js': notifier - }); - - opts = { - 'pkg': { - 'name': './../../ctor', - 'version': '0.0.0' - }, - 'updates': true - }; - ctor( opts ); - - function notifier() { - return { - 'notify': notify - }; - } - - function notify() { - t.ok( true, 'checks registry' ); - t.end(); - } -}); - -tape( 'if the `updates` option is `true` and insufficient package meta data is provided, the returned instance does not check for available updates in the package registry (no pkg name)', function test( t ) { - var ctor; - var proc; - var opts; - - proc = { - 'exit': noop, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc, - './notifier.js': notifier - }); - - opts = { - 'pkg': { - 'version': '0.0.0' - }, - 'updates': true - }; - ctor( opts ); - - t.ok( true, 'is ok' ); - t.end(); - - function notifier() { - return { - 'notify': notify - }; - } - - function notify() { - t.fail( 'should never be called' ); - } -}); - -tape( 'if the `updates` option is `true` and insufficient package meta data is provided, the returned instance does not check for available updates in the package registry (no pkg version)', function test( t ) { - var ctor; - var proc; - var opts; - - proc = { - 'exit': noop, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc, - './notifier.js': notifier - }); - - opts = { - 'pkg': { - 'name': './../../ctor' - }, - 'updates': true - }; - ctor( opts ); - - t.ok( true, 'is ok' ); - t.end(); - - function notifier() { - return { - 'notify': notify - }; - } - - function notify() { - t.fail( 'should never be called' ); - } -}); - -tape( 'if the `updates` option is `true` and insufficient package meta data is provided, the returned instance does not check for available updates in the package registry (no pkg data)', function test( t ) { - var ctor; - var proc; - var opts; - - proc = { - 'exit': noop, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc, - './notifier.js': notifier - }); - - opts = { - 'updates': true - }; - ctor( opts ); - - t.ok( true, 'is ok' ); - t.end(); - - function notifier() { - return { - 'notify': notify - }; - } - - function notify() { - t.fail( 'should never be called' ); - } -}); - -tape( 'the instance has a method which returns command-line arguments', function test( t ) { - var expected; - var actual; - var argv; - var ctor; - var proc; - var opts; - var cli; - - argv = [ - '/usr/local/bin/node', - 'foo.js', - 'foo', - 'bar', - '-a=b', - '--c', - 'd', - 'baz' - ]; - argv[ '@noCallThru' ] = true; - proc = { - 'exit': noop, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr(), - 'argv': argv - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'updates': false - }; - cli = ctor( opts ); - - expected = [ 'foo', 'bar', 'baz' ]; - actual = cli.args(); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the instance has a method which returns command-line flags', function test( t ) { - var expected; - var actual; - var argv; - var ctor; - var proc; - var opts; - var cli; - - argv = [ - '/usr/local/bin/node', - 'foo.js', - 'foo', - 'bar', - '-a=b', - '--c', - 'd', - '--e', - '-f', - '-ghi', - '--beep', - 'boop', - 'baz' - ]; - argv[ '@noCallThru' ] = true; - proc = { - 'exit': noop, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr(), - 'argv': argv - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'updates': false - }; - cli = ctor( opts ); - - expected = { - 'a': 'b', - 'c': 'd', - 'e': true, - 'f': true, - 'g': true, - 'h': true, - 'i': true, - 'beep': 'boop' - }; - actual = cli.flags(); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the constructor supports providing an array of command-line arguments', function test( t ) { - var expected; - var actual; - var argv; - var ctor; - var proc; - var opts; - var cli; - - argv = [ - '/usr/local/bin/node', - 'foo.js', - 'foo', - 'bar', - '-a=b', - '--c', - 'd', - '--e', - '-f', - '-ghi', - '--beep', - 'boop', - 'baz' - ]; - argv[ '@noCallThru' ] = true; - proc = { - 'exit': noop, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'updates': false, - 'argv': argv - }; - cli = ctor( opts ); - - expected = { - 'a': 'b', - 'c': 'd', - 'e': true, - 'f': true, - 'g': true, - 'h': true, - 'i': true, - 'beep': 'boop' - }; - actual = cli.flags(); - - t.deepEqual( actual, expected, 'returns expected flags' ); - - expected = [ - 'foo', - 'bar', - 'baz' - ]; - actual = cli.args(); - - t.deepEqual( actual, expected, 'returns expected arguments' ); - t.end(); -}); - -tape( 'if the flag `-h` is set and is an alias for `--help`, the instance prints help text to `stderr` and exits', opts, function test( t ) { - var expected; - var actual; - var fpath; - var fopts; - var ctor; - var proc; - var opts; - var log; - - proc = { - 'exit': exit, - 'exitCode': -1, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr(), - 'argv': [ '/usr/local/bin/node', 'foo.js', '-h' ] - }; - log = { - 'error': write - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc, - './console.js': log - }); - - fpath = join( __dirname, 'fixtures', 'usage.txt' ); - fopts = { - 'encoding': 'utf8' - }; - expected = readFileSync( fpath, fopts ); - - actual = ''; - - opts = { - 'updates': false, - 'help': expected, - 'options': { - 'boolean': [ - 'help', - 'version' - ], - 'alias': { - 'help': [ - 'h' - ], - 'version': [ - 'V' - ] - } - } - }; - ctor( opts ); - - t.strictEqual( actual, expected, 'writes expected text' ); - t.strictEqual( proc.exitCode, 0, 'sets exit code to 0' ); - t.end(); - - function write( data ) { - actual += data.toString(); - } - - function exit() { - t.fail( 'should not be called' ); - } -}); - -tape( 'if the flag `-h` is set and is an alias for `--help`, the instance prints help text to `stderr` and exits (browser)', function test( t ) { - var expected; - var actual; - var ctor; - var proc; - var opts; - var log; - - proc = { - 'exit': exit, - 'exitCode': -1, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr(), - 'argv': [ '/usr/local/bin/node', 'foo.js', '-h' ] - }; - log = { - 'error': write - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc, - './console.js': log - }); - - expected = 'Usage: boop [options] '; - actual = ''; - - opts = { - 'updates': false, - 'help': expected, - 'options': { - 'boolean': [ - 'help', - 'version' - ], - 'alias': { - 'help': [ - 'h' - ], - 'version': [ - 'V' - ] - } - } - }; - ctor( opts ); - - t.strictEqual( actual, expected, 'writes expected text' ); - t.strictEqual( proc.exitCode, 0, 'sets exit code to 0' ); - t.end(); - - function write( data ) { - actual += data.toString(); - } - - function exit() { - t.fail( 'should not be called' ); - } -}); - -tape( 'if the flag `--help` is set, the instance prints help text to `stderr` and exits', opts, function test( t ) { - var expected; - var actual; - var fpath; - var fopts; - var ctor; - var proc; - var opts; - var log; - - proc = { - 'exit': exit, - 'exitCode': -1, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr(), - 'argv': [ '/usr/local/bin/node', 'foo.js', '--help' ] - }; - log = { - 'error': write - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc, - './console.js': log - }); - - fpath = join( __dirname, 'fixtures', 'usage.txt' ); - fopts = { - 'encoding': 'utf8' - }; - expected = readFileSync( fpath, fopts ); - - actual = ''; - - opts = { - 'updates': false, - 'help': expected, - 'options': { - 'boolean': [ - 'help', - 'version' - ] - } - }; - ctor( opts ); - - t.strictEqual( actual, expected, 'writes expected text' ); - t.strictEqual( proc.exitCode, 0, 'sets exit code to 0' ); - t.end(); - - function write( data ) { - actual += data.toString(); - } - - function exit() { - t.fail( 'should not be called' ); - } -}); - -tape( 'if the flag `--help` is set, the instance prints help text to `stderr` and exits (browser)', function test( t ) { - var expected; - var actual; - var ctor; - var proc; - var opts; - var log; - - proc = { - 'exit': exit, - 'exitCode': -1, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr(), - 'argv': [ '/usr/local/bin/node', 'foo.js', '--help' ] - }; - log = { - 'error': write - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc, - './console.js': log - }); - - expected = 'Usage: boop [options] '; - - actual = ''; - - opts = { - 'updates': false, - 'help': expected, - 'options': { - 'boolean': [ - 'help', - 'version' - ] - } - }; - ctor( opts ); - - t.strictEqual( actual, expected, 'writes expected text' ); - t.strictEqual( proc.exitCode, 0, 'sets exit code to 0' ); - t.end(); - - function write( data ) { - actual += data.toString(); - } - - function exit() { - t.fail( 'should not be called' ); - } -}); - -tape( 'if the flag `-V` is set and is an alias for `--version`, the instance prints the version to `stderr` and exits', function test( t ) { - var expected; - var actual; - var ctor; - var proc; - var opts; - var log; - - proc = { - 'exit': exit, - 'exitCode': -1, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr(), - 'argv': [ '/usr/local/bin/node', 'foo.js', '-V' ] - }; - log = { - 'error': write - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc, - './console.js': log - }); - - expected = '1.1.1'; - actual = ''; - - opts = { - 'version': '1.1.1', - 'updates': false, - 'options': { - 'boolean': [ - 'help', - 'version' - ], - 'alias': { - 'help': [ - 'h' - ], - 'version': [ - 'V' - ] - } - } - }; - ctor( opts ); - - t.strictEqual( actual, expected, 'writes expected text' ); - t.strictEqual( proc.exitCode, 0, 'sets exit code to 0' ); - t.end(); - - function write( data ) { - actual += data.toString(); - } - - function exit() { - t.fail( 'should not be called' ); - } -}); - -tape( 'if the flag `--version` is set, the instance prints the version to `stderr` and exits', function test( t ) { - var expected; - var actual; - var ctor; - var proc; - var opts; - var log; - - proc = { - 'exit': exit, - 'exitCode': -1, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr(), - 'argv': [ '/usr/local/bin/node', 'foo.js', '--version' ] - }; - log = { - 'error': write - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc, - './console.js': log - }); - - expected = '1.1.1'; - actual = ''; - - opts = { - 'version': '1.1.1', - 'updates': false, - 'options': { - 'boolean': [ - 'help', - 'version' - ], - 'alias': { - 'help': [ - 'h' - ], - 'version': [ - 'V' - ] - } - } - }; - ctor( opts ); - - t.strictEqual( actual, expected, 'writes expected text' ); - t.strictEqual( proc.exitCode, 0, 'sets exit code to 0' ); - t.end(); - - function write( data ) { - actual += data.toString(); - } - - function exit() { - t.fail( 'should not be called' ); - } -}); - -tape( 'the instance provides a method to forcefully exit', function test( t ) { - var ctor; - var proc; - var opts; - var cli; - - proc = { - 'exit': exit, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'updates': false - }; - cli = ctor( opts ); - cli.exit(); - - function exit( code ) { - t.strictEqual( code, 0, 'is provided expected value' ); - t.end(); - } -}); - -tape( 'the instance provides a method to forcefully exit and provide an exit code', function test( t ) { - var ctor; - var proc; - var opts; - var cli; - - proc = { - 'exit': exit, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'updates': false - }; - cli = ctor( opts ); - cli.exit( 5 ); - - function exit( code ) { - t.strictEqual( code, 5, 'is provided expected value' ); - t.end(); - } -}); - -tape( 'the instance method to forcefully exit throws an error if not provided a nonnegative integer', function test( t ) { - var values; - var proc; - var ctor; - var cli; - var i; - - proc = { - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'updates': false - }; - cli = ctor( opts ); - - values = [ - '5', - -1, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - cli.exit( value ); - }; - } -}); - -tape( 'the instance provides a method to gracefully exit', function test( t ) { - var ctor; - var proc; - var opts; - var cli; - - proc = { - 'exit': noop, - 'exitCode': -1, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'updates': false - }; - cli = ctor( opts ); - cli.close(); - - t.strictEqual( proc.exitCode, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the instance provides a method to gracefully exit and provide an exit code', function test( t ) { - var ctor; - var proc; - var opts; - var cli; - - proc = { - 'exit': noop, - 'exitCode': -1, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'updates': false - }; - cli = ctor( opts ); - cli.close( 5 ); - - t.strictEqual( proc.exitCode, 5, 'returns expected value' ); - t.end(); -}); - -tape( 'the instance method to gracefully exit throws an error if not provided a nonnegative integer', function test( t ) { - var values; - var proc; - var ctor; - var cli; - var i; - - proc = { - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'updates': false - }; - cli = ctor( opts ); - - values = [ - '5', - -1, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - cli.close( value ); - }; - } -}); - -tape( 'the instance provides a method to exit due to an error', function test( t ) { - var ctor; - var proc; - var opts; - var log; - var cli; - var err; - - proc = { - 'exit': noop, - 'exitCode': -1, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - log = { - 'error': onError - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc, - './console.js': log - }); - - opts = { - 'updates': false - }; - cli = ctor( opts ); - - err = new Error( 'invalid operation' ); - cli.error( err ); - - t.strictEqual( proc.exitCode, 1, 'returns expected value' ); - t.end(); - - function onError() { - t.ok( true, 'method to log error message to `stdout` is invoked' ); - } -}); - -tape( 'the instance provides a method to exit due to an error (exit code)', function test( t ) { - var ctor; - var proc; - var opts; - var log; - var cli; - var err; - - proc = { - 'exit': noop, - 'exitCode': -1, - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - log = { - 'error': onError - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc, - './console.js': log - }); - - opts = { - 'updates': false - }; - cli = ctor( opts ); - - err = new Error( 'invalid operation' ); - cli.error( err, 2 ); - - t.strictEqual( proc.exitCode, 2, 'returns expected value' ); - t.end(); - - function onError() { - t.ok( true, 'method to log error message to `stdout` is invoked' ); - } -}); - -tape( 'the instance method to exit due to an error throws an error if not provided an error object for the first argument', function test( t ) { - var values; - var proc; - var ctor; - var cli; - var i; - - proc = { - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'updates': false - }; - cli = ctor( opts ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - cli.error( value ); - }; - } -}); - -tape( 'the instance method to exit due to an error throws an error if not provided an error object for the first argument (exit code)', function test( t ) { - var values; - var proc; - var ctor; - var cli; - var i; - - proc = { - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'updates': false - }; - cli = ctor( opts ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - cli.error( value, 1 ); - }; - } -}); - -tape( 'the instance method to exit due to an error throws an error if not provided a nonnegative integer as an exit code', function test( t ) { - var values; - var proc; - var ctor; - var cli; - var i; - - proc = { - 'title': '', - 'stdout': stdout(), - 'stderr': stderr() - }; - - ctor = proxyquire( './../lib/main.js', { - './process.js': proc - }); - - opts = { - 'updates': false - }; - cli = ctor( opts ); - - values = [ - '5', - -1, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - cli.error( new Error( 'invalid operation' ), value ); - }; - } -}); diff --git a/ctor/test/test.validate.js b/ctor/test/test.validate.js deleted file mode 100644 index 3c8574e..0000000 --- a/ctor/test/test.validate.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an `options` argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `pkg` option which is not an object', function test( t ) { - var values; - var opts; - var err; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - opts = { - 'pkg': values[ i ] - }; - err = validate( {}, opts ); - t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `options` option which is not an object', function test( t ) { - var values; - var opts; - var err; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - opts = { - 'options': values[ i ] - }; - err = validate( {}, opts ); - t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `argv` option which is not an array', function test( t ) { - var values; - var opts; - var err; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - opts = { - 'argv': values[ i ] - }; - err = validate( {}, opts ); - t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `title` option which is not a string or a boolean', function test( t ) { - var values; - var opts; - var err; - var i; - - values = [ - 5, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - opts = { - 'title': values[ i ] - }; - err = validate( {}, opts ); - t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `version` option which is not a string', function test( t ) { - var values; - var opts; - var err; - var i; - - values = [ - 5, - true, - false, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - opts = { - 'version': values[ i ] - }; - err = validate( {}, opts ); - t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `help` option which is not a string', function test( t ) { - var values; - var opts; - var err; - var i; - - values = [ - 5, - true, - false, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - opts = { - 'help': values[ i ] - }; - err = validate( {}, opts ); - t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `updates` option which is not a boolean', function test( t ) { - var values; - var opts; - var err; - var i; - - values = [ - '5', - 5, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - opts = { - 'updates': values[ i ] - }; - err = validate( {}, opts ); - t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns `null` if all options are valid', function test( t ) { - var options; - var opts; - var err; - - opts = {}; - options = { - 'pkg': { - 'name': 'beep', - 'version': '0.0.0' - }, - 'argv': [], - 'options': {}, - 'title': false, - 'version': '0.0.0', - 'updates': false, - 'help': 'Usage: beep [options] ' - }; - - err = validate( opts, options ); - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, options, 'sets options' ); - - t.end(); -}); - -tape( 'the function will ignore unrecognized options', function test( t ) { - var options; - var opts; - var err; - - opts = {}; - options = { - 'beep': true, - 'boop': 'bop' - }; - - err = validate( opts, options ); - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, {}, 'ignores unrecognized options' ); - - t.end(); -}); diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 3176df5..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CLI = require( './../../ctor' ); - -/** -* Interface describing the `cli` namespace. -*/ -interface Namespace { - /** - * Command-line interface. - */ - CLI: typeof CLI; -} - -/** -* Command-line interface. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c2dd14e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 6c26d3b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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/index.js b/index.js new file mode 100644 index 0000000..5f38d53 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,r;e=this,r=function(e){"use strict";var r="function"==typeof Object.defineProperty?Object.defineProperty:null,t=Object.defineProperty;function n(e){return"number"==typeof e}function i(e){var r,t="";for(r=0;r0&&(t-=1),n=e.toExponential(t)):n=e.toPrecision(r.precision),r.alternate||(n=f.call(n,w,"$1e"),n=f.call(n,y,"e"),n=f.call(n,b,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return n=f.call(n,g,"e+0$1"),n=f.call(n,d,"e-0$1"),r.alternate&&(n=f.call(n,h,"$1."),n=f.call(n,v,"$1.e")),e>=0&&r.sign&&(n=r.sign+n),n=r.specifier===u.call(r.specifier)?u.call(n):c.call(n)}function k(e){var r,t="";for(r=0;r127)throw new Error("invalid character code. Value: "+i.arg);i.arg=x(s)?String(i.arg):E(s)}break;case"e":case"E":case"f":case"F":case"g":case"G":if(r||(i.precision=6),u=parseFloat(i.arg),!isFinite(u)){if(!n(i.arg))throw new Error("invalid floating-point number. Value: "+p);u=i.arg,i.padZeros=!1}i.arg=m(u,i);break;default:throw new Error("invalid specifier: "+i.specifier)}i.maxWidth>=0&&i.arg.length>i.maxWidth&&(i.arg=i.arg.substring(0,i.maxWidth)),i.padZeros?i.arg=o(i.arg,i.width||i.precision,i.padRight):i.width&&(i.arg=(d=i.arg,h=i.width,v=i.padRight,b=void 0,(b=h-d.length)<0?d:d=v?d+k(b):k(b)+d)),p+=i.arg||"",c+=1}return p}var T=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function $(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function S(e){var r,t,n,i;for(t=[],i=0,n=T.exec(e);n;)(r=e.slice(i,T.lastIndex-n[0].length)).length&&t.push(r),"%"===n[6]?t.push("%"):t.push($(n)),i=T.lastIndex,n=T.exec(e);return(r=e.slice(i)).length&&t.push(r),t}function F(e){var r,t;if("string"!=typeof e)throw new TypeError(F("invalid argument. First argument must be a string. Value: `%s`.",e));for(r=[S(e)],t=1;t0||t[1]>10?e.exitCode=r:(e.exitCode=r,setTimeout((function(){e.exit(r)}),10))}function ee(){return this instanceof ee?this:new ee}X=ee.prototype,B(X,"notify",{configurable:!1,enumerable:!1,writable:!1,value:function(){}});var re=function(e,r){r||(r={});var t={bools:{},strings:{},unknownFn:null};"function"==typeof r.unknown&&(t.unknownFn=r.unknown),"boolean"==typeof r.boolean&&r.boolean?t.allBools=!0:[].concat(r.boolean).filter(Boolean).forEach((function(e){t.bools[e]=!0}));var n={};function i(e){return n[e].some((function(e){return t.bools[e]}))}Object.keys(r.alias||{}).forEach((function(e){n[e]=[].concat(r.alias[e]),n[e].forEach((function(r){n[r]=[e].concat(n[e].filter((function(e){return r!==e})))}))})),[].concat(r.string).filter(Boolean).forEach((function(e){t.strings[e]=!0,n[e]&&[].concat(n[e]).forEach((function(e){t.strings[e]=!0}))}));var o=r.default||{},a={_:[]};function s(e,r,n){for(var i=e,o=0;o1){if("number"!=typeof r||!U(r)||r<0)throw new TypeError(F("invalid argument. Second argument must be a nonnegative integer. Value: `%s`.",r));t=r}else t=1;K.error("Error: %s",e.message),Y(J,t)})),ie(oe.prototype,"exit",(function(e){if(0===arguments.length)return J.exit(0);if("number"!=typeof e||!U(e)||e<0)throw new TypeError(F("invalid argument. Must provide a nonnegative integer. Value: `%s`.",e));J.exit(e)}));var ae={};return function(e,r,t){B(e,r,{configurable:!1,enumerable:!0,writable:!1,value:t})}(ae,"CLI",oe),ae},"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("process")):"function"==typeof define&&define.amd?define(["process"],r):(e="undefined"!=typeof globalThis?globalThis:e||self).ns=r(e.require$$0); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..1c060fc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../node_modules/@stdlib/utils/define-property/lib/define_property.js","../node_modules/@stdlib/utils/define-property/lib/builtin.js","../node_modules/@stdlib/string/base/format-interpolate/lib/is_number.js","../node_modules/@stdlib/string/base/format-interpolate/lib/zero_pad.js","../node_modules/@stdlib/string/base/format-interpolate/lib/format_integer.js","../node_modules/@stdlib/string/base/format-interpolate/lib/format_double.js","../node_modules/@stdlib/string/base/format-interpolate/lib/space_pad.js","../node_modules/@stdlib/string/base/format-interpolate/lib/main.js","../node_modules/@stdlib/string/base/format-interpolate/lib/is_string.js","../node_modules/@stdlib/string/base/format-tokenize/lib/main.js","../node_modules/@stdlib/string/format/lib/main.js","../node_modules/@stdlib/string/format/lib/is_string.js","../node_modules/@stdlib/utils/define-property/lib/polyfill.js","../node_modules/@stdlib/utils/define-property/lib/index.js","../node_modules/@stdlib/utils/define-property/lib/has_define_property_support.js","../node_modules/minimist/index.js","../ctor/lib/is_integer.js","../ctor/lib/validate.js","../node_modules/@stdlib/utils/define-nonenumerable-read-only-property/lib/main.js","../ctor/lib/process.js","../ctor/lib/console.js","../ctor/lib/exit_code.js","../ctor/lib/notifier.js","../node_modules/@stdlib/utils/noop/lib/main.js","../ctor/lib/main.js","../lib/index.js","../node_modules/@stdlib/utils/define-read-only-property/lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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\nvar main = ( typeof Object.defineProperty === 'function' ) ? Object.defineProperty : null;\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Defines (or modifies) an object property.\n*\n* ## Notes\n*\n* - Property descriptors come in two flavors: **data descriptors** and **accessor descriptors**. A data descriptor is a property that has a value, which may or may not be writable. An accessor descriptor is a property described by a getter-setter function pair. A descriptor must be one of these two flavors and cannot be both.\n*\n* @name defineProperty\n* @type {Function}\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {Object} descriptor - property descriptor\n* @param {boolean} [descriptor.configurable=false] - boolean indicating if property descriptor can be changed and if the property can be deleted from the provided object\n* @param {boolean} [descriptor.enumerable=false] - boolean indicating if the property shows up when enumerating object properties\n* @param {boolean} [descriptor.writable=false] - boolean indicating if the value associated with the property can be changed with an assignment operator\n* @param {*} [descriptor.value] - property value\n* @param {(Function|void)} [descriptor.get=undefined] - function which serves as a getter for the property, or, if no getter, undefined. When the property is accessed, a getter function is called without arguments and with the `this` context set to the object through which the property is accessed (which may not be the object on which the property is defined due to inheritance). The return value will be used as the property value.\n* @param {(Function|void)} [descriptor.set=undefined] - function which serves as a setter for the property, or, if no setter, undefined. When assigning a property value, a setter function is called with one argument (the value being assigned to the property) and with the `this` context set to the object through which the property is assigned.\n* @throws {TypeError} first argument must be an object\n* @throws {TypeError} third argument must be an object\n* @throws {Error} property descriptor cannot have both a value and a setter and/or getter\n* @returns {Object} object with added property\n*\n* @example\n* var obj = {};\n*\n* defineProperty( obj, 'foo', {\n* 'value': 'bar'\n* });\n*\n* var str = obj.foo;\n* // returns 'bar'\n*/\nvar defineProperty = Object.defineProperty;\n\n\n// EXPORTS //\n\nexport default defineProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a number primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number primitive\n*\n* @example\n* var bool = isNumber( 3.14 );\n* // returns true\n*\n* @example\n* var bool = isNumber( NaN );\n* // returns true\n*\n* @example\n* var bool = isNumber( new Number( 3.14 ) );\n* // returns false\n*/\nfunction isNumber( value ) {\n\treturn ( typeof value === 'number' ); // NOTE: we inline the `isNumber.isPrimitive` function from `@stdlib/assert/is-number` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Tests if a string starts with a minus sign (`-`).\n*\n* @private\n* @param {string} str - input string\n* @returns {boolean} boolean indicating if a string starts with a minus sign (`-`)\n*/\nfunction startsWithMinus( str ) {\n\treturn str[ 0 ] === '-';\n}\n\n/**\n* Returns a string of `n` zeros.\n*\n* @private\n* @param {number} n - number of zeros\n* @returns {string} string of zeros\n*/\nfunction zeros( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += '0';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with zeros to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction zeroPad( str, width, right ) {\n\tvar negative = false;\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tif ( startsWithMinus( str ) ) {\n\t\tnegative = true;\n\t\tstr = str.substr( 1 );\n\t}\n\tstr = ( right ) ?\n\t\tstr + zeros( pad ) :\n\t\tzeros( pad ) + str;\n\tif ( negative ) {\n\t\tstr = '-' + str;\n\t}\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default zeroPad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isNumber from './is_number.js';\nimport zeroPad from './zero_pad.js';\n\n// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies.\nvar lowercase = String.prototype.toLowerCase;\nvar uppercase = String.prototype.toUpperCase;\n\n\n// MAIN //\n\n/**\n* Formats a token object argument as an integer.\n*\n* @private\n* @param {Object} token - token object\n* @throws {Error} must provide a valid integer\n* @returns {string} formatted token argument\n*/\nfunction formatInteger( token ) {\n\tvar base;\n\tvar out;\n\tvar i;\n\n\tswitch ( token.specifier ) {\n\tcase 'b':\n\t\t// Case: %b (binary)\n\t\tbase = 2;\n\t\tbreak;\n\tcase 'o':\n\t\t// Case: %o (octal)\n\t\tbase = 8;\n\t\tbreak;\n\tcase 'x':\n\tcase 'X':\n\t\t// Case: %x, %X (hexadecimal)\n\t\tbase = 16;\n\t\tbreak;\n\tcase 'd':\n\tcase 'i':\n\tcase 'u':\n\tdefault:\n\t\t// Case: %d, %i, %u (decimal)\n\t\tbase = 10;\n\t\tbreak;\n\t}\n\tout = token.arg;\n\ti = parseInt( out, 10 );\n\tif ( !isFinite( i ) ) { // NOTE: We use the global `isFinite` function here instead of `@stdlib/math/base/assert/is-finite` in order to avoid circular dependencies.\n\t\tif ( !isNumber( out ) ) {\n\t\t\tthrow new Error( 'invalid integer. Value: ' + out );\n\t\t}\n\t\ti = 0;\n\t}\n\tif ( i < 0 && ( token.specifier === 'u' || base !== 10 ) ) {\n\t\ti = 0xffffffff + i + 1;\n\t}\n\tif ( i < 0 ) {\n\t\tout = ( -i ).toString( base );\n\t\tif ( token.precision ) {\n\t\t\tout = zeroPad( out, token.precision, token.padRight );\n\t\t}\n\t\tout = '-' + out;\n\t} else {\n\t\tout = i.toString( base );\n\t\tif ( !i && !token.precision ) {\n\t\t\tout = '';\n\t\t} else if ( token.precision ) {\n\t\t\tout = zeroPad( out, token.precision, token.padRight );\n\t\t}\n\t\tif ( token.sign ) {\n\t\t\tout = token.sign + out;\n\t\t}\n\t}\n\tif ( base === 16 ) {\n\t\tif ( token.alternate ) {\n\t\t\tout = '0x' + out;\n\t\t}\n\t\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\t\tuppercase.call( out ) :\n\t\t\tlowercase.call( out );\n\t}\n\tif ( base === 8 ) {\n\t\tif ( token.alternate && out.charAt( 0 ) !== '0' ) {\n\t\t\tout = '0' + out;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\n// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies.\nvar abs = Math.abs; // eslint-disable-line stdlib/no-builtin-math\nvar lowercase = String.prototype.toLowerCase;\nvar uppercase = String.prototype.toUpperCase;\nvar replace = String.prototype.replace;\n\n\n// VARIABLES //\n\nvar RE_EXP_POS_DIGITS = /e\\+(\\d)$/;\nvar RE_EXP_NEG_DIGITS = /e-(\\d)$/;\nvar RE_ONLY_DIGITS = /^(\\d+)$/;\nvar RE_DIGITS_BEFORE_EXP = /^(\\d+)e/;\nvar RE_TRAILING_PERIOD_ZERO = /\\.0$/;\nvar RE_PERIOD_ZERO_EXP = /\\.0*e/;\nvar RE_ZERO_BEFORE_EXP = /(\\..*[^0])0*e/;\n\n\n// MAIN //\n\n/**\n* Formats a token object argument as a floating-point number.\n*\n* @private\n* @param {number} f - parsed number\n* @param {Object} token - token object\n* @throws {Error} must provide a valid floating-point number\n* @returns {string} formatted token argument\n*/\nfunction formatDouble( f, token ) {\n\tvar digits;\n\tvar out;\n\n\tswitch ( token.specifier ) {\n\tcase 'e':\n\tcase 'E':\n\t\tout = f.toExponential( token.precision );\n\t\tbreak;\n\tcase 'f':\n\tcase 'F':\n\t\tout = f.toFixed( token.precision );\n\t\tbreak;\n\tcase 'g':\n\tcase 'G':\n\t\tif ( abs( f ) < 0.0001 ) {\n\t\t\tdigits = token.precision;\n\t\t\tif ( digits > 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport isNumber from './is_number.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar f;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\tf = parseFloat( token.arg );\n\t\t\t\tif ( !isFinite( f ) ) { // NOTE: We use the global `isFinite` function here instead of `@stdlib/math/base/assert/is-finite` in order to avoid circular dependencies.\n\t\t\t\t\tif ( !isNumber( token.arg ) ) {\n\t\t\t\t\t\tthrow new Error( 'invalid floating-point number. Value: ' + out );\n\t\t\t\t\t}\n\t\t\t\t\t// Case: NaN, Infinity, or -Infinity\n\t\t\t\t\tf = token.arg;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( f, token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\t// Check for an escaped percent sign `%%`...\n\t\tif ( match[ 6 ] === '%' ) {\n\t\t\ttokens.push( '%' );\n\t\t} else {\n\t\t\ttokens.push( parse( match ) );\n\t\t}\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport interpolate from './../../base/format-interpolate';\nimport tokenize from './../../base/format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-underscore-dangle, no-proto */\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar objectProtoype = Object.prototype;\nvar toStr = objectProtoype.toString;\nvar defineGetter = objectProtoype.__defineGetter__;\nvar defineSetter = objectProtoype.__defineSetter__;\nvar lookupGetter = objectProtoype.__lookupGetter__;\nvar lookupSetter = objectProtoype.__lookupSetter__;\n\n\n// MAIN //\n\n/**\n* Defines (or modifies) an object property.\n*\n* ## Notes\n*\n* - Property descriptors come in two flavors: **data descriptors** and **accessor descriptors**. A data descriptor is a property that has a value, which may or may not be writable. An accessor descriptor is a property described by a getter-setter function pair. A descriptor must be one of these two flavors and cannot be both.\n*\n* @param {Object} obj - object on which to define the property\n* @param {string} prop - property name\n* @param {Object} descriptor - property descriptor\n* @param {boolean} [descriptor.configurable=false] - boolean indicating if property descriptor can be changed and if the property can be deleted from the provided object\n* @param {boolean} [descriptor.enumerable=false] - boolean indicating if the property shows up when enumerating object properties\n* @param {boolean} [descriptor.writable=false] - boolean indicating if the value associated with the property can be changed with an assignment operator\n* @param {*} [descriptor.value] - property value\n* @param {(Function|void)} [descriptor.get=undefined] - function which serves as a getter for the property, or, if no getter, undefined. When the property is accessed, a getter function is called without arguments and with the `this` context set to the object through which the property is accessed (which may not be the object on which the property is defined due to inheritance). The return value will be used as the property value.\n* @param {(Function|void)} [descriptor.set=undefined] - function which serves as a setter for the property, or, if no setter, undefined. When assigning a property value, a setter function is called with one argument (the value being assigned to the property) and with the `this` context set to the object through which the property is assigned.\n* @throws {TypeError} first argument must be an object\n* @throws {TypeError} third argument must be an object\n* @throws {Error} property descriptor cannot have both a value and a setter and/or getter\n* @returns {Object} object with added property\n*\n* @example\n* var obj = {};\n*\n* defineProperty( obj, 'foo', {\n* 'value': 'bar'\n* });\n*\n* var str = obj.foo;\n* // returns 'bar'\n*/\nfunction defineProperty( obj, prop, descriptor ) {\n\tvar prototype;\n\tvar hasValue;\n\tvar hasGet;\n\tvar hasSet;\n\n\tif ( typeof obj !== 'object' || obj === null || toStr.call( obj ) === '[object Array]' ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) );\n\t}\n\tif ( typeof descriptor !== 'object' || descriptor === null || toStr.call( descriptor ) === '[object Array]' ) {\n\t\tthrow new TypeError( format( 'invalid argument. Property descriptor must be an object. Value: `%s`.', descriptor ) );\n\t}\n\thasValue = ( 'value' in descriptor );\n\tif ( hasValue ) {\n\t\tif (\n\t\t\tlookupGetter.call( obj, prop ) ||\n\t\t\tlookupSetter.call( obj, prop )\n\t\t) {\n\t\t\t// Override `__proto__` to avoid touching inherited accessors:\n\t\t\tprototype = obj.__proto__;\n\t\t\tobj.__proto__ = objectProtoype;\n\n\t\t\t// Delete property as existing getters/setters prevent assigning value to specified property:\n\t\t\tdelete obj[ prop ];\n\t\t\tobj[ prop ] = descriptor.value;\n\n\t\t\t// Restore original prototype:\n\t\t\tobj.__proto__ = prototype;\n\t\t} else {\n\t\t\tobj[ prop ] = descriptor.value;\n\t\t}\n\t}\n\thasGet = ( 'get' in descriptor );\n\thasSet = ( 'set' in descriptor );\n\n\tif ( hasValue && ( hasGet || hasSet ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot specify one or more accessors and a value or writable attribute in the property descriptor.' );\n\t}\n\n\tif ( hasGet && defineGetter ) {\n\t\tdefineGetter.call( obj, prop, descriptor.get );\n\t}\n\tif ( hasSet && defineSetter ) {\n\t\tdefineSetter.call( obj, prop, descriptor.set );\n\t}\n\treturn obj;\n}\n\n\n// EXPORTS //\n\nexport default defineProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Define (or modify) an object property.\n*\n* @module @stdlib/utils/define-property\n*\n* @example\n* import defineProperty from '@stdlib/utils/define-property';\n*\n* var obj = {};\n* defineProperty( obj, 'foo', {\n* 'value': 'bar',\n* 'writable': false,\n* 'configurable': false,\n* 'enumerable': false\n* });\n* obj.foo = 'boop'; // => throws\n*/\n\n// MODULES //\n\nimport hasDefinePropertySupport from './has_define_property_support.js';\nimport builtin from './builtin.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar defineProperty;\nif ( hasDefinePropertySupport() ) {\n\tdefineProperty = builtin;\n} else {\n\tdefineProperty = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default defineProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './define_property.js';\n\n\n// MAIN //\n\n/**\n* Tests for `Object.defineProperty` support.\n*\n* @private\n* @returns {boolean} boolean indicating if an environment has `Object.defineProperty` support\n*\n* @example\n* var bool = hasDefinePropertySupport();\n* // returns \n*/\nfunction hasDefinePropertySupport() {\n\t// Test basic support...\n\ttry {\n\t\tdefineProperty( {}, 'x', {} );\n\t\treturn true;\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default hasDefinePropertySupport;\n","'use strict';\n\nfunction hasKey(obj, keys) {\n\tvar o = obj;\n\tkeys.slice(0, -1).forEach(function (key) {\n\t\to = o[key] || {};\n\t});\n\n\tvar key = keys[keys.length - 1];\n\treturn key in o;\n}\n\nfunction isNumber(x) {\n\tif (typeof x === 'number') { return true; }\n\tif ((/^0x[0-9a-f]+$/i).test(x)) { return true; }\n\treturn (/^[-+]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(e[-+]?\\d+)?$/).test(x);\n}\n\nfunction isConstructorOrProto(obj, key) {\n\treturn (key === 'constructor' && typeof obj[key] === 'function') || key === '__proto__';\n}\n\nmodule.exports = function (args, opts) {\n\tif (!opts) { opts = {}; }\n\n\tvar flags = {\n\t\tbools: {},\n\t\tstrings: {},\n\t\tunknownFn: null,\n\t};\n\n\tif (typeof opts.unknown === 'function') {\n\t\tflags.unknownFn = opts.unknown;\n\t}\n\n\tif (typeof opts.boolean === 'boolean' && opts.boolean) {\n\t\tflags.allBools = true;\n\t} else {\n\t\t[].concat(opts.boolean).filter(Boolean).forEach(function (key) {\n\t\t\tflags.bools[key] = true;\n\t\t});\n\t}\n\n\tvar aliases = {};\n\n\tfunction aliasIsBoolean(key) {\n\t\treturn aliases[key].some(function (x) {\n\t\t\treturn flags.bools[x];\n\t\t});\n\t}\n\n\tObject.keys(opts.alias || {}).forEach(function (key) {\n\t\taliases[key] = [].concat(opts.alias[key]);\n\t\taliases[key].forEach(function (x) {\n\t\t\taliases[x] = [key].concat(aliases[key].filter(function (y) {\n\t\t\t\treturn x !== y;\n\t\t\t}));\n\t\t});\n\t});\n\n\t[].concat(opts.string).filter(Boolean).forEach(function (key) {\n\t\tflags.strings[key] = true;\n\t\tif (aliases[key]) {\n\t\t\t[].concat(aliases[key]).forEach(function (k) {\n\t\t\t\tflags.strings[k] = true;\n\t\t\t});\n\t\t}\n\t});\n\n\tvar defaults = opts.default || {};\n\n\tvar argv = { _: [] };\n\n\tfunction argDefined(key, arg) {\n\t\treturn (flags.allBools && (/^--[^=]+$/).test(arg))\n\t\t\t|| flags.strings[key]\n\t\t\t|| flags.bools[key]\n\t\t\t|| aliases[key];\n\t}\n\n\tfunction setKey(obj, keys, value) {\n\t\tvar o = obj;\n\t\tfor (var i = 0; i < keys.length - 1; i++) {\n\t\t\tvar key = keys[i];\n\t\t\tif (isConstructorOrProto(o, key)) { return; }\n\t\t\tif (o[key] === undefined) { o[key] = {}; }\n\t\t\tif (\n\t\t\t\to[key] === Object.prototype\n\t\t\t\t|| o[key] === Number.prototype\n\t\t\t\t|| o[key] === String.prototype\n\t\t\t) {\n\t\t\t\to[key] = {};\n\t\t\t}\n\t\t\tif (o[key] === Array.prototype) { o[key] = []; }\n\t\t\to = o[key];\n\t\t}\n\n\t\tvar lastKey = keys[keys.length - 1];\n\t\tif (isConstructorOrProto(o, lastKey)) { return; }\n\t\tif (\n\t\t\to === Object.prototype\n\t\t\t|| o === Number.prototype\n\t\t\t|| o === String.prototype\n\t\t) {\n\t\t\to = {};\n\t\t}\n\t\tif (o === Array.prototype) { o = []; }\n\t\tif (o[lastKey] === undefined || flags.bools[lastKey] || typeof o[lastKey] === 'boolean') {\n\t\t\to[lastKey] = value;\n\t\t} else if (Array.isArray(o[lastKey])) {\n\t\t\to[lastKey].push(value);\n\t\t} else {\n\t\t\to[lastKey] = [o[lastKey], value];\n\t\t}\n\t}\n\n\tfunction setArg(key, val, arg) {\n\t\tif (arg && flags.unknownFn && !argDefined(key, arg)) {\n\t\t\tif (flags.unknownFn(arg) === false) { return; }\n\t\t}\n\n\t\tvar value = !flags.strings[key] && isNumber(val)\n\t\t\t? Number(val)\n\t\t\t: val;\n\t\tsetKey(argv, key.split('.'), value);\n\n\t\t(aliases[key] || []).forEach(function (x) {\n\t\t\tsetKey(argv, x.split('.'), value);\n\t\t});\n\t}\n\n\tObject.keys(flags.bools).forEach(function (key) {\n\t\tsetArg(key, defaults[key] === undefined ? false : defaults[key]);\n\t});\n\n\tvar notFlags = [];\n\n\tif (args.indexOf('--') !== -1) {\n\t\tnotFlags = args.slice(args.indexOf('--') + 1);\n\t\targs = args.slice(0, args.indexOf('--'));\n\t}\n\n\tfor (var i = 0; i < args.length; i++) {\n\t\tvar arg = args[i];\n\t\tvar key;\n\t\tvar next;\n\n\t\tif ((/^--.+=/).test(arg)) {\n\t\t\t// Using [\\s\\S] instead of . because js doesn't support the\n\t\t\t// 'dotall' regex modifier. See:\n\t\t\t// http://stackoverflow.com/a/1068308/13216\n\t\t\tvar m = arg.match(/^--([^=]+)=([\\s\\S]*)$/);\n\t\t\tkey = m[1];\n\t\t\tvar value = m[2];\n\t\t\tif (flags.bools[key]) {\n\t\t\t\tvalue = value !== 'false';\n\t\t\t}\n\t\t\tsetArg(key, value, arg);\n\t\t} else if ((/^--no-.+/).test(arg)) {\n\t\t\tkey = arg.match(/^--no-(.+)/)[1];\n\t\t\tsetArg(key, false, arg);\n\t\t} else if ((/^--.+/).test(arg)) {\n\t\t\tkey = arg.match(/^--(.+)/)[1];\n\t\t\tnext = args[i + 1];\n\t\t\tif (\n\t\t\t\tnext !== undefined\n\t\t\t\t&& !(/^(-|--)[^-]/).test(next)\n\t\t\t\t&& !flags.bools[key]\n\t\t\t\t&& !flags.allBools\n\t\t\t\t&& (aliases[key] ? !aliasIsBoolean(key) : true)\n\t\t\t) {\n\t\t\t\tsetArg(key, next, arg);\n\t\t\t\ti += 1;\n\t\t\t} else if ((/^(true|false)$/).test(next)) {\n\t\t\t\tsetArg(key, next === 'true', arg);\n\t\t\t\ti += 1;\n\t\t\t} else {\n\t\t\t\tsetArg(key, flags.strings[key] ? '' : true, arg);\n\t\t\t}\n\t\t} else if ((/^-[^-]+/).test(arg)) {\n\t\t\tvar letters = arg.slice(1, -1).split('');\n\n\t\t\tvar broken = false;\n\t\t\tfor (var j = 0; j < letters.length; j++) {\n\t\t\t\tnext = arg.slice(j + 2);\n\n\t\t\t\tif (next === '-') {\n\t\t\t\t\tsetArg(letters[j], next, arg);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif ((/[A-Za-z]/).test(letters[j]) && next[0] === '=') {\n\t\t\t\t\tsetArg(letters[j], next.slice(1), arg);\n\t\t\t\t\tbroken = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t(/[A-Za-z]/).test(letters[j])\n\t\t\t\t\t&& (/-?\\d+(\\.\\d*)?(e-?\\d+)?$/).test(next)\n\t\t\t\t) {\n\t\t\t\t\tsetArg(letters[j], next, arg);\n\t\t\t\t\tbroken = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (letters[j + 1] && letters[j + 1].match(/\\W/)) {\n\t\t\t\t\tsetArg(letters[j], arg.slice(j + 2), arg);\n\t\t\t\t\tbroken = true;\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tsetArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tkey = arg.slice(-1)[0];\n\t\t\tif (!broken && key !== '-') {\n\t\t\t\tif (\n\t\t\t\t\targs[i + 1]\n\t\t\t\t\t&& !(/^(-|--)[^-]/).test(args[i + 1])\n\t\t\t\t\t&& !flags.bools[key]\n\t\t\t\t\t&& (aliases[key] ? !aliasIsBoolean(key) : true)\n\t\t\t\t) {\n\t\t\t\t\tsetArg(key, args[i + 1], arg);\n\t\t\t\t\ti += 1;\n\t\t\t\t} else if (args[i + 1] && (/^(true|false)$/).test(args[i + 1])) {\n\t\t\t\t\tsetArg(key, args[i + 1] === 'true', arg);\n\t\t\t\t\ti += 1;\n\t\t\t\t} else {\n\t\t\t\t\tsetArg(key, flags.strings[key] ? '' : true, arg);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (!flags.unknownFn || flags.unknownFn(arg) !== false) {\n\t\t\t\targv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));\n\t\t\t}\n\t\t\tif (opts.stopEarly) {\n\t\t\t\targv._.push.apply(argv._, args.slice(i + 1));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tObject.keys(defaults).forEach(function (k) {\n\t\tif (!hasKey(argv, k.split('.'))) {\n\t\t\tsetKey(argv, k.split('.'), defaults[k]);\n\n\t\t\t(aliases[k] || []).forEach(function (x) {\n\t\t\t\tsetKey(argv, x.split('.'), defaults[k]);\n\t\t\t});\n\t\t}\n\t});\n\n\tif (opts['--']) {\n\t\targv['--'] = notFlags.slice();\n\t} else {\n\t\tnotFlags.forEach(function (k) {\n\t\t\targv._.push(k);\n\t\t});\n\t}\n\n\treturn argv;\n};\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a finite double-precision floating-point number is an integer.\n*\n* @private\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is an integer\n*\n* @example\n* var bool = isInteger( 1.0 );\n* // returns true\n*\n* @example\n* var bool = isInteger( 3.14 );\n* // returns false\n*/\nfunction isInteger( x ) {\n\t// NOTE: we explicitly avoid using `@stdlib/math/base/special` here in order to avoid circular dependencies.\n\treturn ( Math.floor( x ) === x ); // eslint-disable-line stdlib/no-builtin-math\n}\n\n\n// EXPORTS //\n\nexport default isInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar hasOwnProp = Object.prototype.hasOwnProperty;\nvar isArray = Array.isArray;\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {Object} [options.pkg] - package meta information (package.json)\n* @param {string} [options.version] - command-line interface version\n* @param {string} [options.help] - help text\n* @param {(string|boolean)} [options.title] - process title or a boolean indicating whether to set the process title\n* @param {boolean} [options.updates] - boolean indicating whether to check if a command-line interface is an outdated version\n* @param {Array} [options.argv] - command-line arguments\n* @param {Options} [options.options] - command-line interface options\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'pkg': {},\n* 'version': '1.0.0',\n* 'help': 'Usage: beep [options] ',\n* 'title': 'foo',\n* 'updates': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( typeof options !== 'object' || options === null || isArray( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp.call( options, 'pkg' ) ) {\n\t\topts.pkg = options.pkg;\n\t\tif ( typeof opts.pkg !== 'object' || opts.pkg === null || isArray( opts.pkg ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an object. Option: `%s`.', 'pkg', opts.pkg ) );\n\t\t}\n\t}\n\tif ( hasOwnProp.call( options, 'help' ) ) {\n\t\topts.help = options.help;\n\t\tif ( typeof opts.help !== 'string' ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'help', opts.help ) );\n\t\t}\n\t}\n\tif ( hasOwnProp.call( options, 'version' ) ) {\n\t\topts.version = options.version;\n\t\tif ( typeof opts.version !== 'string' ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'version', opts.version ) );\n\t\t}\n\t}\n\tif ( hasOwnProp.call( options, 'title' ) ) {\n\t\topts.title = options.title;\n\t\tif ( typeof opts.title !== 'string' && typeof opts.title !== 'boolean' ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either a string or boolean primitive. Option: `%s`.', 'title', opts.title ) );\n\t\t}\n\t}\n\tif ( hasOwnProp.call( options, 'updates' ) ) {\n\t\topts.updates = options.updates;\n\t\tif ( typeof opts.updates !== 'boolean' ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'updates', opts.updates ) );\n\t\t}\n\t}\n\tif ( hasOwnProp.call( options, 'argv' ) ) {\n\t\topts.argv = options.argv;\n\t\tif ( !isArray( opts.argv ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array. Option: `%s`.', 'argv', opts.argv ) );\n\t\t}\n\t}\n\tif ( hasOwnProp.call( options, 'options' ) ) {\n\t\topts.options = options.options;\n\t\tif ( typeof opts.options !== 'object' || opts.options === null || isArray( opts.options ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a plain object. Option: `%s`.', 'options', opts.options ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a non-enumerable read-only property.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {*} value - value to set\n*\n* @example\n* var obj = {};\n*\n* setNonEnumerableReadOnly( obj, 'foo', 'bar' );\n*\n* try {\n* obj.foo = 'boop';\n* } catch ( err ) {\n* console.error( err.message );\n* }\n*/\nfunction setNonEnumerableReadOnly( obj, prop, value ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': false,\n\t\t'writable': false,\n\t\t'value': value\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setNonEnumerableReadOnly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar proc = require( 'process' );\n\n\n// EXPORTS //\n\nexport default proc;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// EXPORTS //\n\nexport default console;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport proc from './process.js';\n\n\n// VARIABLES //\n\nvar NODE_VERSION = proc.versions.node;\nvar TIMEOUT = 10; // ms\n\n\n// MAIN //\n\n/**\n* Sets the process exit code.\n*\n* @private\n* @param {Object} proc - process object\n* @param {NonNegativeInteger} code - exit code\n* @returns {void}\n*/\nfunction exitCode( proc, code ) {\n\tvar v;\n\n\t// Handle old Node.js versions lacking `process.exitCode` support...\n\tv = NODE_VERSION.split( '.' );\n\tv[ 0 ] = parseInt( v[ 0 ], 10 );\n\tv[ 1 ] = parseInt( v[ 1 ], 10 );\n\n\t// Case: >0.x.x\n\tif ( v[ 0 ] > 0 ) {\n\t\tproc.exitCode = code;\n\t\treturn;\n\t}\n\t// Case: >0.10.x\n\tif ( v[ 1 ] > 10 ) {\n\t\tproc.exitCode = code;\n\t\treturn;\n\t}\n\t// Case: <= 0.10.x\n\tproc.exitCode = code; // NOTE: assigning this property should have no operational effect in older Node.js versions\n\n\t// No choice but to forcefully exit during a subsequent turn of the event loop (note: the timeout duration is arbitrary; the main idea is to hopefully allow the event loop queue to drain before exiting the process, including the flushing of stdio streams which can be non-blocking/asynchronous)...\n\tsetTimeout( onTimeout, TIMEOUT );\n\n\t/**\n\t* Callback invoked during a subsequent turn of the event loop.\n\t*\n\t* @private\n\t*/\n\tfunction onTimeout() {\n\t\tproc.exit( code );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default exitCode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n// FIXME: remove this stub and create a stdlib equivalent of update-notifier\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport noop from '@stdlib/utils/noop';\n\n\n// MAIN //\n\n/**\n* Notifier constructor.\n*\n* @private\n* @constructor\n* @returns {Notifier} notifier instance\n*\n* @example\n* var notifier = new Notifier();\n*/\nfunction Notifier() {\n\tif ( !(this instanceof Notifier) ) {\n\t\treturn new Notifier();\n\t}\n\treturn this;\n}\n\n/**\n* Notifies whether a new version is available.\n*\n* @private\n* @name notify\n* @memberof Notifier.prototype\n* @type {Function}\n*/\nsetReadOnly( Notifier.prototype, 'notify', noop );\n\n\n// EXPORTS //\n\nexport default Notifier;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* No operation.\n*\n* @example\n* noop();\n* // ...does nothing.\n*/\nfunction noop() {\n\t// Empty function...\n}\n\n\n// EXPORTS //\n\nexport default noop;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable stdlib/jsdoc-doctest, no-restricted-syntax */\n\n'use strict';\n\n// MODULES //\n\nvar parseArgs = require( 'minimist' ); // TODO: replace with stdlib equivalent\nimport format from '@stdlib/string/format';\nimport defaults from './defaults.json';\nimport isInteger from './is_integer.js';\nimport validate from './validate.js';\nimport proc from './process.js';\nimport log from './console.js';\nimport exitCode from './exit_code.js';\nimport notifier from './notifier.js';\n\n\n// VARIABLES //\n\n// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies. This should not be problematic as (1) this package is unlikely to be used outside of Node.js and, thus, in environments lacking support for the built-in APIs, and (2) most of the historical bugs for the respective APIs were in environments such as IE and not the versions of V8 included in Node.js >= v0.10.x.\nvar defineProperty = Object.defineProperty;\nvar objectKeys = Object.keys;\n\n\n// FUNCTIONS //\n\n/**\n* Defines a read-only non-enumerable property.\n*\n* @private\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {*} value - value to set\n*\n* @example\n* var obj = {};\n*\n* setReadOnly( obj, 'foo', 'bar' );\n*\n* try {\n* obj.foo = 'boop';\n* } catch ( err ) {\n* console.error( err.message );\n* }\n*/\nfunction setReadOnly( obj, prop, value ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': false,\n\t\t'writable': false,\n\t\t'value': value\n\t});\n}\n\n\n// MAIN //\n\n/**\n* Command-line interface constructor.\n*\n* @constructor\n* @param {Options} [options] - options\n* @param {Object} [options.pkg={}] - package meta information (package.json)\n* @param {string} [options.version] - command-line interface version\n* @param {string} [options.help=\"\"] - help text\n* @param {(string|boolean)} [options.title=true] - process title or a boolean indicating whether to set the process title\n* @param {boolean} [options.updates=true] - boolean indicating whether to check if a command-line interface is an outdated version\n* @param {Array} [options.argv] - command-line arguments\n* @param {Options} [options.options={}] - command-line interface options\n* @throws {TypeError} must provide an object\n* @throws {TypeError} must provide valid options\n* @returns {CLI} command-line interface\n*\n* @example\n* var opts = {\n* 'pkg': require( './path/to/package.json' ),\n* 'help': 'Usage: beep [options] ',\n* 'title': 'foo',\n* 'updates': true,\n* 'options': {\n* 'boolean': [\n* 'help',\n* 'version'\n* ]\n* }\n* };\n* var cli = new CLI( opts );\n* // returns \n*\n* cli.close();\n*/\nfunction CLI( options ) {\n\tvar nopts;\n\tvar flags;\n\tvar keys;\n\tvar opts;\n\tvar argv;\n\tvar args;\n\tvar self;\n\tvar err;\n\tif ( !( this instanceof CLI ) ) {\n\t\tif ( arguments.length ) {\n\t\t\treturn new CLI( options );\n\t\t}\n\t\treturn new CLI();\n\t}\n\topts = {\n\t\t'pkg': {},\n\t\t'help': defaults.help,\n\t\t'title': defaults.title,\n\t\t'version': defaults.version,\n\t\t'updates': defaults.updates,\n\t\t'argv': defaults.argv,\n\t\t'options': {}\n\t};\n\tif ( arguments.length ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tself = this;\n\n\t// Force the process to exit if an error is encountered when writing to `stdout` or `stderr`:\n\tproc.stdout.on( 'error', proc.exit );\n\tproc.stderr.on( 'error', proc.exit );\n\n\t/**\n\t* Returns parsed command-line arguments.\n\t*\n\t* @name args\n\t* @memberof CLI#\n\t* @type {Function}\n\t* @returns {StringArray} parsed command-line arguments\n\t*\n\t* @example\n\t* var cli = new CLI();\n\t*\n\t* var args = cli.args();\n\t* // returns \n\t*/\n\tsetReadOnly( this, 'args', getArgs );\n\n\t/**\n\t* Returns parsed command-line flags.\n\t*\n\t* @name flags\n\t* @memberof CLI#\n\t* @type {Function}\n\t* @returns {Object} parsed command-line flags\n\t*\n\t* @example\n\t* var cli = new CLI();\n\t*\n\t* var flags = cli.flags();\n\t* // returns \n\t*/\n\tsetReadOnly( this, 'flags', getFlags );\n\n\t/**\n\t* Prints usage information and exits the process.\n\t*\n\t* @name help\n\t* @memberof CLI#\n\t* @type {Function}\n\t*\n\t* @example\n\t* var opts = {\n\t* 'help': 'Usage: beep [options] '\n\t* };\n\t* var cli = new CLI( opts );\n\t*\n\t* cli.help();\n\t* // => 'Usage: beep [options] '\n\t*/\n\tsetReadOnly( this, 'help', help );\n\n\t/**\n\t* Prints the command-line interface version and exits the process.\n\t*\n\t* @name version\n\t* @memberof CLI#\n\t* @type {Function}\n\t*\n\t* @example\n\t* var opts = {\n\t* 'pkg': require( './path/to/package.json' )\n\t* };\n\t* var cli = new CLI( opts );\n\t*\n\t* cli.version();\n\t* // => '#.#.#'\n\t*/\n\tsetReadOnly( this, 'version', version );\n\n\t// Check whether to set the process title...\n\tif ( opts.title === true && opts.pkg ) {\n\t\tif ( typeof opts.pkg.bin === 'object' && opts.pkg.bin !== null ) {\n\t\t\tkeys = objectKeys( opts.pkg.bin );\n\n\t\t\t// Note: we don't have a way of knowing which command name in the `bin` hash was invoked; thus, we assume the first entry.\n\t\t\tproc.title = keys[ 0 ];\n\t\t} else if ( opts.pkg.name ) {\n\t\t\tproc.title = opts.pkg.name;\n\t\t}\n\t} else if ( opts.title ) {\n\t\tproc.title = opts.title;\n\t}\n\t// Check whether to notify the user of a new CLI version...\n\tif ( opts.updates && opts.pkg && opts.pkg.name && opts.pkg.version ) {\n\t\tnopts = {\n\t\t\t'pkg': opts.pkg\n\t\t};\n\t\tnotifier( nopts ).notify();\n\t}\n\t// Determine the command-line interface version...\n\tif ( !opts.version && opts.pkg && opts.pkg.version ) {\n\t\topts.version = opts.pkg.version;\n\t}\n\t// Parse command-line arguments:\n\tif ( opts.argv ) {\n\t\topts.argv = opts.argv.slice( 2 );\n\t} else {\n\t\topts.argv = proc.argv.slice( 2 );\n\t}\n\targv = parseArgs( opts.argv, opts.options );\n\n\t// Cache parsed arguments:\n\targs = argv._;\n\tdelete argv._;\n\tflags = argv;\n\n\t// Determine whether to print help text...\n\tif ( flags.help ) {\n\t\treturn this.help( 0 );\n\t}\n\t// Determine whether to print the version...\n\tif ( flags.version ) {\n\t\treturn this.version();\n\t}\n\treturn this;\n\n\t/**\n\t* Returns parsed command-line arguments.\n\t*\n\t* @private\n\t* @returns {StringArray} parsed command-line arguments\n\t*/\n\tfunction getArgs() {\n\t\treturn args.slice();\n\t}\n\n\t/**\n\t* Returns parsed command-line flags.\n\t*\n\t* @private\n\t* @returns {Object} parsed command-line flags\n\t*/\n\tfunction getFlags() {\n\t\tvar keys;\n\t\tvar o;\n\t\tvar k;\n\t\tvar i;\n\n\t\tkeys = objectKeys( flags );\n\t\to = {};\n\t\tfor ( i = 0; i < keys.length; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\to[ k ] = flags[ k ];\n\t\t}\n\t\treturn o;\n\t}\n\n\t/**\n\t* Prints usage information.\n\t*\n\t* ## Notes\n\t*\n\t* - Upon printing usage information, the function forces the process to exit.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} [code=0] - exit code\n\t*/\n\tfunction help( code ) {\n\t\tlog.error( opts.help );\n\t\tself.close( code || 0 );\n\t}\n\n\t/**\n\t* Prints the command-line interface version.\n\t*\n\t* ## Notes\n\t*\n\t* - Upon printing the version, the function forces the process to exit.\n\t*\n\t* @private\n\t*/\n\tfunction version() {\n\t\tlog.error( opts.version );\n\t\tself.close();\n\t}\n}\n\n/**\n* Gracefully exits the command-line interface and the calling process.\n*\n* @name close\n* @memberof CLI.prototype\n* @type {Function}\n* @param {NonNegativeInteger} [code=0] - exit code\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {void}\n*\n* @example\n* var cli = new CLI();\n*\n* // Gracefully exit:\n* cli.close();\n*/\nsetReadOnly( CLI.prototype, 'close', function close( code ) {\n\tif ( arguments.length === 0 ) {\n\t\texitCode( proc, 0 );\n\t\treturn;\n\t}\n\tif ( typeof code !== 'number' || !isInteger( code ) || code < 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', code ) );\n\t}\n\texitCode( proc, code );\n});\n\n/**\n* Exits the command-line interface and the calling process due to an error.\n*\n* ## Notes\n*\n* - The value assigned to the `message` property of the provided `Error` object is printed to `stderr` prior to exiting the command-line interface and the calling process.\n*\n* @name error\n* @memberof CLI.prototype\n* @type {Function}\n* @param {Error} error - error object\n* @param {NonNegativeInteger} [code=1] - exit code\n* @throws {TypeError} first argument must be an error object\n* @throws {TypeError} second argument must be a nonnegative integer\n* @returns {void}\n*\n* @example\n* var cli = new CLI();\n*\n* // ...\n*\n* // Create an error object:\n* var err = new Error( 'invalid operation' );\n*\n* // Exit the process:\n* cli.error( err, 0 );\n*/\nsetReadOnly( CLI.prototype, 'error', function onError( error, code ) {\n\tvar c;\n\tif ( !( error instanceof Error ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an error object. Value: `%s`.', error ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( typeof code !== 'number' || !isInteger( code ) || code < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%s`.', code ) );\n\t\t}\n\t\tc = code;\n\t} else {\n\t\tc = 1;\n\t}\n\tlog.error( 'Error: %s', error.message );\n\texitCode( proc, c );\n});\n\n/**\n* Forces the command-line interface (and the calling process) to exit.\n*\n* @name exit\n* @memberof CLI.prototype\n* @type {Function}\n* @param {NonNegativeInteger} [code=0] - exit code\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {void}\n*\n* @example\n* var cli = new CLI();\n*\n* // Forcefully exit:\n* cli.exit();\n*/\nsetReadOnly( CLI.prototype, 'exit', function exit( code ) {\n\tif ( arguments.length === 0 ) {\n\t\treturn proc.exit( 0 );\n\t}\n\tif ( typeof code !== 'number' || !isInteger( code ) || code < 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', code ) );\n\t}\n\tproc.exit( code );\n});\n\n\n// EXPORTS //\n\nexport default CLI;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 CLI\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/cli/ctor}\n*/\nimport CLI from './../ctor';\nsetReadOnly( ns, 'CLI', CLI );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a read-only property.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {*} value - value to set\n*\n* @example\n* var obj = {};\n*\n* setReadOnly( obj, 'foo', 'bar' );\n*\n* try {\n* obj.foo = 'boop';\n* } catch ( err ) {\n* console.error( err.message );\n* }\n*/\nfunction setReadOnly( obj, prop, value ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': value\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setReadOnly;\n"],"names":["main","Object","defineProperty","isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","f","digits","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","parseFloat","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply","objectProtoype","toStr","defineGetter","__defineGetter__","defineSetter","__defineSetter__","lookupGetter","__lookupGetter__","lookupSetter","__lookupSetter__","err","hasDefinePropertySupport","builtin","obj","prop","descriptor","hasValue","hasGet","hasSet","__proto__","get","set","defineProperty$2","x","test","isConstructorOrProto","key","isInteger","floor","hasOwnProp","hasOwnProperty","proc","require$$0","log","console","NODE_VERSION","versions","node","exitCode","code","v","split","setTimeout","exit","Notifier","this","configurable","enumerable","writable","parseArgs","opts","bools","strings","unknownFn","unknown","boolean","allBools","concat","filter","Boolean","forEach","aliases","aliasIsBoolean","some","keys","alias","y","string","k","defaults","default","argv","_","setKey","o","undefined","Number","lastKey","setArg","val","argDefined","notFlags","next","m","letters","broken","stopEarly","objectKeys","setReadOnly","CLI","options","self","pkg","help","title","version","updates","validate","stdout","on","stderr","error","close","bin","name","notifier","notify","c","message","ns"],"mappings":";0CAsBA,IAAIA,EAA0C,mBAA1BC,OAAOC,eAAkCD,OAAOC,eAAiB,KCiCjFA,EAAiBD,OAAOC,eCjB5B,SAASC,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,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qB,iBAAToH,IAAsBZ,EAAWY,IAAUA,EAAO,EAC7D,MAAM,IAAI7D,UAAWiB,EAAQ,qEAAsE4C,IAEpGD,EAAUP,EAAMQ,EAJf,MAFAD,EAAUP,EAAM,EAOlB,IA6BAyD,GAAaC,GAAIjK,UAAW,SAAS,SAAkB6K,EAAO9D,GAC7D,IAAIoE,EACJ,KAAQN,aAAiBlK,OACxB,MAAM,IAAIuC,UAAWiB,EAAQ,yEAA0E0G,IAExG,GAAKxH,UAAU1D,OAAS,EAAI,CAC3B,GAAqB,iBAAToH,IAAsBZ,EAAWY,IAAUA,EAAO,EAC7D,MAAM,IAAI7D,UAAWiB,EAAQ,gFAAiF4C,IAE/GoE,EAAIpE,CACN,MACEoE,EAAI,EAEL1E,EAAIoE,MAAO,YAAaA,EAAMO,SAC9BtE,EAAUP,EAAM4E,EACjB,IAkBAnB,GAAaC,GAAIjK,UAAW,QAAQ,SAAe+G,GAClD,GAA0B,IAArB1D,UAAU1D,OACd,OAAO4G,EAAKY,KAAM,GAEnB,GAAqB,iBAATJ,IAAsBZ,EAAWY,IAAUA,EAAO,EAC7D,MAAM,IAAI7D,UAAWiB,EAAQ,qEAAsE4C,IAEpGR,EAAKY,KAAMJ,EACZ,IC5XI,IAAAsE,GAAK,CAAG,SCSZ,SAAsBhG,EAAKC,EAAMtG,GAChCF,EAAgBuG,EAAKC,EAAM,CAC1BgC,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZxI,MAASA,GAEX,CDNAgL,CAAaqB,GAAI,MAAOpB","x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,18,23,26]} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ecb60a1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 CLI -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/cli/ctor} -*/ -setReadOnly( ns, 'CLI', require( './../ctor' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/package.json b/package.json index 85fb548..2a7027d 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,7 @@ "version": "0.3.3", "description": "Command-line interface.", "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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,35 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/string": "github:stdlib-js/string#main", - "@stdlib/utils": "github:stdlib-js/utils#main", - "minimist": "^1.2.0" - }, - "devDependencies": { - "@stdlib/assert": "github:stdlib-js/assert#main", - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/fs": "github:stdlib-js/fs#main", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..82e10f6 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..71ed434 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index e682e93..0000000 --- a/test/test.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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.strictEqual( keys.length > 0, true, 'has keys' ); - t.end(); -});