From dd036e09fcf168942ec8d11ce5c2352e0c0d3518 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 31 May 2022 23:56:13 +0000 Subject: [PATCH 001/161] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/bundle.yml | 504 ---- .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 160 -- .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 106 +- benchmark/benchmark.js | 82 - bin/cli | 88 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 50 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 131 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 166 -- 42 files changed, 2710 insertions(+), 3993 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/bundle.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/bundle.yml b/.github/workflows/bundle.yml deleted file mode 100644 index 10f472a..0000000 --- a/.github/workflows/bundle.yml +++ /dev/null @@ -1,504 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: bundle - -# Workflow triggers: -on: - # Allow workflow to be manually run: - workflow_dispatch: - - # Run workflow upon completion of `productionize` workflow: - workflow_run: - workflows: ["productionize"] - types: [completed] - -# Workflow jobs: -jobs: - - # 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 - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Checkout production branch: - - name: 'Checkout production branch' - run: | - git fetch --all - git checkout -b production origin/production - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # 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 - - # 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 branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, checkout branch and rebase on `main`: - - name: 'If `deno` exists, checkout branch and rebase on `main`' - if: steps.deno-branch-exists.outputs.remote-exists - continue-on-error: true - run: | - git checkout -b deno origin/deno - git rebase main -s recursive -X ours - while [ $? -ne 0 ]; do - git rebase --skip - done - - # If `deno` does not exist, checkout `main` and create `deno` branch: - - name: 'If `deno` does not exist, checkout `main` and create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout main - git checkout -b deno - - # 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 rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs 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: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno --force - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Checkout production branch: - - name: 'Checkout production branch' - run: | - git fetch --all - git checkout -b production origin/production - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -124,78 +117,7 @@ console.log( codePointAt( '🌷', 1, true ) ); -* * * - -
- -## CLI - -
- -## Installation - -To use the module as a general utility, install the module globally - -```bash -npm install -g @stdlib/string-code-point-at -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] [] --pos= - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -228,7 +150,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -298,7 +220,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d6fa37c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var x; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu() * UNICODE_MAX ); - out = codePointAt( fromCodePoint( x ), 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var x; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu() * UNICODE_MAX ); - out = String.prototype.codePointAt.call( fromCodePoint( x ), 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index cd15ed7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ca79247..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. - - backward: boolean (optional) - Backward iteration for low surrogates. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 493a2cd..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The function does not compile if provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - codePointAt(); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7f67b39..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] [] --pos= - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ee22639 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var s=e.isPrimitive,n=i.isPrimitive,o=r.isPrimitive,d=t;var a=function(e,i,r){var t,a,m,h;if(!n(e))throw new TypeError(d("0h83N",e));if(!o(i))throw new TypeError(d("invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.",i));if(i>=e.length)throw new RangeError(d("invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.",i));if(arguments.length>2){if(!s(r))throw new TypeError(d("0h8B3",r));a=r}else a=!1;return(t=e.charCodeAt(i))>=55296&&t<=56319&&i=56320&&t<=57343&&i>=1?(m=t,55296<=(h=e.charCodeAt(i-1))&&h<=56319?1024*(h-55296)+(m-56320)+65536:m):t};export{a as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..71bdf41 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar format = require( '@stdlib/error-tools-fmtprodmsg' );\n\n\n// VARIABLES //\n\n// Factors for converting individual surrogates\nvar Ox10000 = 0x10000|0; // 65536\nvar Ox400 = 0x400|0; // 1024\n\n// Range for a high surrogate\nvar OxD800 = 0xD800|0; // 55296\nvar OxDBFF = 0xDBFF|0; // 56319\n\n// Range for a low surrogate\nvar OxDC00 = 0xDC00|0; // 56320\nvar OxDFFF = 0xDFFF|0; // 57343\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* ## Notes\n*\n* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF).\n* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate.\n*\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a number having a nonnegative integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar code;\n\tvar FLG;\n\tvar low;\n\tvar hi;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83N', str ) );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\tcode = str.charCodeAt( idx );\n\n\t// High surrogate\n\tif ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) {\n\t\thi = code;\n\t\tlow = str.charCodeAt( idx+1 );\n\t\tif ( OxDC00 <= low && low <= OxDFFF ) {\n\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t}\n\t\treturn hi;\n\t}\n\t// Low surrogate - support only if backward iteration is desired\n\tif ( FLG ) {\n\t\tif ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) {\n\t\t\thi = str.charCodeAt( idx-1 );\n\t\t\tlow = code;\n\t\t\tif ( OxD800 <= hi && hi <= OxDBFF ) {\n\t\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t\t}\n\t\t\treturn low;\n\t\t}\n\t}\n\treturn code;\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar codePointAt = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n"],"names":["isBoolean","require$$0","isPrimitive","isString","require$$1","isNonNegativeInteger","require$$2","format","require$$3","lib","str","idx","backward","code","FLG","low","hi","TypeError","length","RangeError","arguments","charCodeAt"],"mappings":";;oWAsBA,IAAIA,EAAYC,EAAuCC,YACnDC,EAAWC,EAAsCF,YACjDG,EAAuBC,EAAmDJ,YAC1EK,EAASC,EAyGb,ICxFAC,EDqCA,SAAsBC,EAAKC,EAAKC,GAC/B,IAAIC,EACAC,EACAC,EACAC,EAEJ,IAAMb,EAAUO,GACf,MAAM,IAAIO,UAAWV,EAAQ,QAASG,IAEvC,IAAML,EAAsBM,GAC3B,MAAM,IAAIM,UAAWV,EAAQ,8FAA+FI,IAE7H,GAAKA,GAAOD,EAAIQ,OACf,MAAM,IAAIC,WAAYZ,EAAQ,6FAA8FI,IAE7H,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMlB,EAAWY,GAChB,MAAM,IAAIK,UAAWV,EAAQ,QAASK,IAEvCE,EAAMF,OAENE,GAAM,EAKP,OAHAD,EAAOH,EAAIW,WAAYV,KAnEX,OAsEWE,GArEX,OAqE6BF,EAAMD,EAAIQ,OAAS,GAC3DF,EAAKH,EAnEM,QAoEXE,EAAML,EAAIW,WAAYV,EAAI,KACJI,GApEX,MARD,MA6EEC,EA1ED,QA0E6BD,EAtE7B,OARC,MAgFLC,GAGHF,GACCD,GA5EM,OA4EYA,GA3EZ,OA2E8BF,GAAO,GAE/CI,EAAMF,EAlFI,QAiFVG,EAAKN,EAAIW,WAAYV,EAAI,KAEJK,GAlFX,MAJD,MAuFGA,EApFF,QAoF8BD,EAhF9B,OARC,MA0FJA,GAGFF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8a587be..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var codePointAt = require( './main.js' ); - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 90d3bcc..0000000 --- a/lib/main.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); - - -// VARIABLES // - -// Factors for converting individual surrogates -var Ox10000 = 0x10000|0; // 65536 -var Ox400 = 0x400|0; // 1024 - -// Range for a high surrogate -var OxD800 = 0xD800|0; // 55296 -var OxDBFF = 0xDBFF|0; // 56319 - -// Range for a low surrogate -var OxDC00 = 0xDC00|0; // 56320 -var OxDFFF = 0xDFFF|0; // 57343 - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* ## Notes -* -* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF). -* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate. -* -* -* @param {string} str - input string -* @param {NonNegativeInteger} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be a number having a nonnegative integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var code; - var FLG; - var low; - var hi; - - if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', str ) ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) ); - } - if ( idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - code = str.charCodeAt( idx ); - - // High surrogate - if ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) { - hi = code; - low = str.charCodeAt( idx+1 ); - if ( OxDC00 <= low && low <= OxDFFF ) { - return ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000; - } - return hi; - } - // Low surrogate - support only if backward iteration is desired - if ( FLG ) { - if ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) { - hi = str.charCodeAt( idx-1 ); - low = code; - if ( OxD800 <= hi && hi <= OxDBFF ) { - return ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000; - } - return low; - } - } - return code; -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index f5727ca..257c730 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.8", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/cli-ctor": "^0.0.x", - "@stdlib/fs-read-file": "^0.0.x", - "@stdlib/process-read-stdin": "^0.0.x", - "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/string-format": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-windows": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/constants-unicode-max": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/process-exec-path": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-from-code-point": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4796d63 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index 6262e9c..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 979b719..0000000 --- a/test/test.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string primitive', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean primitive', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'string', 7 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 8187e48232a5758ae7f8397b59f7fca30c9abf6d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Jun 2022 23:26:53 +0000 Subject: [PATCH 002/161] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 90d3bcc..df8c1c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -84,7 +84,7 @@ function codePointAt( str, idx, backward ) { var hi; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83N', str ) ); } if ( !isNonNegativeInteger( idx ) ) { throw new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) ); @@ -94,7 +94,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index f5727ca..dc9d01d 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/fs-read-file": "^0.0.x", "@stdlib/process-read-stdin": "^0.0.x", "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", From 4466feae928c9be236702ed6e780b4a21f393aba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 10:56:18 +0000 Subject: [PATCH 003/161] Remove files --- index.d.ts | 45 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2739 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 1fc6118..0000000 --- a/index.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws first argument must be a string -* @throws second argument must be a nonnegative integer -* @throws third argument must be a boolean -* @throws position must be a valid index in string -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ee22639..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var s=e.isPrimitive,n=i.isPrimitive,o=r.isPrimitive,d=t;var a=function(e,i,r){var t,a,m,h;if(!n(e))throw new TypeError(d("0h83N",e));if(!o(i))throw new TypeError(d("invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.",i));if(i>=e.length)throw new RangeError(d("invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.",i));if(arguments.length>2){if(!s(r))throw new TypeError(d("0h8B3",r));a=r}else a=!1;return(t=e.charCodeAt(i))>=55296&&t<=56319&&i=56320&&t<=57343&&i>=1?(m=t,55296<=(h=e.charCodeAt(i-1))&&h<=56319?1024*(h-55296)+(m-56320)+65536:m):t};export{a as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 71bdf41..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar format = require( '@stdlib/error-tools-fmtprodmsg' );\n\n\n// VARIABLES //\n\n// Factors for converting individual surrogates\nvar Ox10000 = 0x10000|0; // 65536\nvar Ox400 = 0x400|0; // 1024\n\n// Range for a high surrogate\nvar OxD800 = 0xD800|0; // 55296\nvar OxDBFF = 0xDBFF|0; // 56319\n\n// Range for a low surrogate\nvar OxDC00 = 0xDC00|0; // 56320\nvar OxDFFF = 0xDFFF|0; // 57343\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* ## Notes\n*\n* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF).\n* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate.\n*\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a number having a nonnegative integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar code;\n\tvar FLG;\n\tvar low;\n\tvar hi;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83N', str ) );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\tcode = str.charCodeAt( idx );\n\n\t// High surrogate\n\tif ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) {\n\t\thi = code;\n\t\tlow = str.charCodeAt( idx+1 );\n\t\tif ( OxDC00 <= low && low <= OxDFFF ) {\n\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t}\n\t\treturn hi;\n\t}\n\t// Low surrogate - support only if backward iteration is desired\n\tif ( FLG ) {\n\t\tif ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) {\n\t\t\thi = str.charCodeAt( idx-1 );\n\t\t\tlow = code;\n\t\t\tif ( OxD800 <= hi && hi <= OxDBFF ) {\n\t\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t\t}\n\t\t\treturn low;\n\t\t}\n\t}\n\treturn code;\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar codePointAt = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n"],"names":["isBoolean","require$$0","isPrimitive","isString","require$$1","isNonNegativeInteger","require$$2","format","require$$3","lib","str","idx","backward","code","FLG","low","hi","TypeError","length","RangeError","arguments","charCodeAt"],"mappings":";;oWAsBA,IAAIA,EAAYC,EAAuCC,YACnDC,EAAWC,EAAsCF,YACjDG,EAAuBC,EAAmDJ,YAC1EK,EAASC,EAyGb,ICxFAC,EDqCA,SAAsBC,EAAKC,EAAKC,GAC/B,IAAIC,EACAC,EACAC,EACAC,EAEJ,IAAMb,EAAUO,GACf,MAAM,IAAIO,UAAWV,EAAQ,QAASG,IAEvC,IAAML,EAAsBM,GAC3B,MAAM,IAAIM,UAAWV,EAAQ,8FAA+FI,IAE7H,GAAKA,GAAOD,EAAIQ,OACf,MAAM,IAAIC,WAAYZ,EAAQ,6FAA8FI,IAE7H,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMlB,EAAWY,GAChB,MAAM,IAAIK,UAAWV,EAAQ,QAASK,IAEvCE,EAAMF,OAENE,GAAM,EAKP,OAHAD,EAAOH,EAAIW,WAAYV,KAnEX,OAsEWE,GArEX,OAqE6BF,EAAMD,EAAIQ,OAAS,GAC3DF,EAAKH,EAnEM,QAoEXE,EAAML,EAAIW,WAAYV,EAAI,KACJI,GApEX,MARD,MA6EEC,EA1ED,QA0E6BD,EAtE7B,OARC,MAgFLC,GAGHF,GACCD,GA5EM,OA4EYA,GA3EZ,OA2E8BF,GAAO,GAE/CI,EAAMF,EAlFI,QAiFVG,EAAKN,EAAIW,WAAYV,EAAI,KAEJK,GAlFX,MAJD,MAuFGA,EApFF,QAoF8BD,EAhF9B,OARC,MA0FJA,GAGFF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4796d63..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 6c951701372c174cf17f45121deef88502fd861e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 10:57:19 +0000 Subject: [PATCH 004/161] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ------ .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 106 +- benchmark/benchmark.js | 82 - bin/cli | 88 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 50 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 131 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 166 -- 42 files changed, 2710 insertions(+), 4011 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index edbe677..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T21:57:50.953Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 128c22e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,681 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs 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 or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -124,78 +117,7 @@ console.log( codePointAt( '🌷', 1, true ) ); -* * * - -
- -## CLI - -
- -## Installation - -To use the module as a general utility, install the module globally - -```bash -npm install -g @stdlib/string-code-point-at -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] [] --pos= - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -228,7 +150,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -298,7 +220,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d6fa37c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var x; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu() * UNICODE_MAX ); - out = codePointAt( fromCodePoint( x ), 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var x; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu() * UNICODE_MAX ); - out = String.prototype.codePointAt.call( fromCodePoint( x ), 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index cd15ed7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ca79247..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. - - backward: boolean (optional) - Backward iteration for low surrogates. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 493a2cd..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The function does not compile if provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - codePointAt(); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7f67b39..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] [] --pos= - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..758bae1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,n,o){var d,a,m,h;if(!i(s))throw new TypeError(r("0h83N",s));if(!t(n))throw new TypeError(r("invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.",n));if(n>=s.length)throw new RangeError(r("invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.",n));if(arguments.length>2){if(!e(o))throw new TypeError(r("0h8B3",o));a=o}else a=!1;return(d=s.charCodeAt(n))>=55296&&d<=56319&&n=56320&&d<=57343&&n>=1?(m=d,55296<=(h=s.charCodeAt(n-1))&&h<=56319?1024*(h-55296)+(m-56320)+65536:m):d}export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7514aaf --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\n// Factors for converting individual surrogates\nvar Ox10000 = 0x10000|0; // 65536\nvar Ox400 = 0x400|0; // 1024\n\n// Range for a high surrogate\nvar OxD800 = 0xD800|0; // 55296\nvar OxDBFF = 0xDBFF|0; // 56319\n\n// Range for a low surrogate\nvar OxDC00 = 0xDC00|0; // 56320\nvar OxDFFF = 0xDFFF|0; // 57343\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* ## Notes\n*\n* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF).\n* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate.\n*\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a number having a nonnegative integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar code;\n\tvar FLG;\n\tvar low;\n\tvar hi;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83N', str ) );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\tcode = str.charCodeAt( idx );\n\n\t// High surrogate\n\tif ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) {\n\t\thi = code;\n\t\tlow = str.charCodeAt( idx+1 );\n\t\tif ( OxDC00 <= low && low <= OxDFFF ) {\n\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t}\n\t\treturn hi;\n\t}\n\t// Low surrogate - support only if backward iteration is desired\n\tif ( FLG ) {\n\t\tif ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) {\n\t\t\thi = str.charCodeAt( idx-1 );\n\t\t\tlow = code;\n\t\t\tif ( OxD800 <= hi && hi <= OxDBFF ) {\n\t\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t\t}\n\t\t\treturn low;\n\t\t}\n\t}\n\treturn code;\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","code","FLG","low","hi","isString","TypeError","format","isNonNegativeInteger","length","RangeError","arguments","isBoolean","charCodeAt"],"mappings":";;iZA+EA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAUP,GACf,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMU,EAAsBT,GAC3B,MAAM,IAAIO,UAAWC,EAAQ,8FAA+FR,IAE7H,GAAKA,GAAOD,EAAIW,OACf,MAAM,IAAIC,WAAYH,EAAQ,6FAA8FR,IAE7H,GAAKY,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvCE,EAAMF,OAENE,GAAM,EAKP,OAHAD,EAAOH,EAAIe,WAAYd,KAnEX,OAsEWE,GArEX,OAqE6BF,EAAMD,EAAIW,OAAS,GAC3DL,EAAKH,EAnEM,QAoEXE,EAAML,EAAIe,WAAYd,EAAI,KACJI,GApEX,MARD,MA6EEC,EA1ED,QA0E6BD,EAtE7B,OARC,MAgFLC,GAGHF,GACCD,GA5EM,OA4EYA,GA3EZ,OA2E8BF,GAAO,GAE/CI,EAAMF,EAlFI,QAiFVG,EAAKN,EAAIe,WAAYd,EAAI,KAEJK,GAlFX,MAJD,MAuFGA,EApFF,QAoF8BD,EAhF9B,OARC,MA0FJA,GAGFF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8a587be..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var codePointAt = require( './main.js' ); - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index df8c1c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -// Factors for converting individual surrogates -var Ox10000 = 0x10000|0; // 65536 -var Ox400 = 0x400|0; // 1024 - -// Range for a high surrogate -var OxD800 = 0xD800|0; // 55296 -var OxDBFF = 0xDBFF|0; // 56319 - -// Range for a low surrogate -var OxDC00 = 0xDC00|0; // 56320 -var OxDFFF = 0xDFFF|0; // 57343 - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* ## Notes -* -* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF). -* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate. -* -* -* @param {string} str - input string -* @param {NonNegativeInteger} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be a number having a nonnegative integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var code; - var FLG; - var low; - var hi; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83N', str ) ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) ); - } - if ( idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - code = str.charCodeAt( idx ); - - // High surrogate - if ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) { - hi = code; - low = str.charCodeAt( idx+1 ); - if ( OxDC00 <= low && low <= OxDFFF ) { - return ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000; - } - return hi; - } - // Low surrogate - support only if backward iteration is desired - if ( FLG ) { - if ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) { - hi = str.charCodeAt( idx-1 ); - low = code; - if ( OxD800 <= hi && hi <= OxDBFF ) { - return ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000; - } - return low; - } - } - return code; -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index dc9d01d..257c730 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.8", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/cli-ctor": "^0.0.x", - "@stdlib/fs-read-file": "^0.0.x", - "@stdlib/process-read-stdin": "^0.0.x", - "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-windows": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/constants-unicode-max": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/process-exec-path": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-from-code-point": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..820b18f --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index 6262e9c..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 979b719..0000000 --- a/test/test.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string primitive', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean primitive', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'string', 7 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 8df5ecba68a998a39d15f3e4ffebd68e7f5a0379 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 17:02:57 +0000 Subject: [PATCH 005/161] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 90d3bcc..df8c1c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -84,7 +84,7 @@ function codePointAt( str, idx, backward ) { var hi; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83N', str ) ); } if ( !isNonNegativeInteger( idx ) ) { throw new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) ); @@ -94,7 +94,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index f5727ca..dc9d01d 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/fs-read-file": "^0.0.x", "@stdlib/process-read-stdin": "^0.0.x", "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", From 7f8bc92b46bfbadf9bd882dce550728993638263 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 09:36:02 +0000 Subject: [PATCH 006/161] Remove files --- index.d.ts | 45 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2739 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 1fc6118..0000000 --- a/index.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws first argument must be a string -* @throws second argument must be a nonnegative integer -* @throws third argument must be a boolean -* @throws position must be a valid index in string -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 758bae1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,n,o){var d,a,m,h;if(!i(s))throw new TypeError(r("0h83N",s));if(!t(n))throw new TypeError(r("invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.",n));if(n>=s.length)throw new RangeError(r("invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.",n));if(arguments.length>2){if(!e(o))throw new TypeError(r("0h8B3",o));a=o}else a=!1;return(d=s.charCodeAt(n))>=55296&&d<=56319&&n=56320&&d<=57343&&n>=1?(m=d,55296<=(h=s.charCodeAt(n-1))&&h<=56319?1024*(h-55296)+(m-56320)+65536:m):d}export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7514aaf..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\n// Factors for converting individual surrogates\nvar Ox10000 = 0x10000|0; // 65536\nvar Ox400 = 0x400|0; // 1024\n\n// Range for a high surrogate\nvar OxD800 = 0xD800|0; // 55296\nvar OxDBFF = 0xDBFF|0; // 56319\n\n// Range for a low surrogate\nvar OxDC00 = 0xDC00|0; // 56320\nvar OxDFFF = 0xDFFF|0; // 57343\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* ## Notes\n*\n* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF).\n* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate.\n*\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a number having a nonnegative integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar code;\n\tvar FLG;\n\tvar low;\n\tvar hi;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83N', str ) );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\tcode = str.charCodeAt( idx );\n\n\t// High surrogate\n\tif ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) {\n\t\thi = code;\n\t\tlow = str.charCodeAt( idx+1 );\n\t\tif ( OxDC00 <= low && low <= OxDFFF ) {\n\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t}\n\t\treturn hi;\n\t}\n\t// Low surrogate - support only if backward iteration is desired\n\tif ( FLG ) {\n\t\tif ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) {\n\t\t\thi = str.charCodeAt( idx-1 );\n\t\t\tlow = code;\n\t\t\tif ( OxD800 <= hi && hi <= OxDBFF ) {\n\t\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t\t}\n\t\t\treturn low;\n\t\t}\n\t}\n\treturn code;\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","code","FLG","low","hi","isString","TypeError","format","isNonNegativeInteger","length","RangeError","arguments","isBoolean","charCodeAt"],"mappings":";;iZA+EA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAUP,GACf,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMU,EAAsBT,GAC3B,MAAM,IAAIO,UAAWC,EAAQ,8FAA+FR,IAE7H,GAAKA,GAAOD,EAAIW,OACf,MAAM,IAAIC,WAAYH,EAAQ,6FAA8FR,IAE7H,GAAKY,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvCE,EAAMF,OAENE,GAAM,EAKP,OAHAD,EAAOH,EAAIe,WAAYd,KAnEX,OAsEWE,GArEX,OAqE6BF,EAAMD,EAAIW,OAAS,GAC3DL,EAAKH,EAnEM,QAoEXE,EAAML,EAAIe,WAAYd,EAAI,KACJI,GApEX,MARD,MA6EEC,EA1ED,QA0E6BD,EAtE7B,OARC,MAgFLC,GAGHF,GACCD,GA5EM,OA4EYA,GA3EZ,OA2E8BF,GAAO,GAE/CI,EAAMF,EAlFI,QAiFVG,EAAKN,EAAIe,WAAYd,EAAI,KAEJK,GAlFX,MAJD,MAuFGA,EApFF,QAoF8BD,EAhF9B,OARC,MA0FJA,GAGFF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 820b18f..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 27ef21dcbeb642ec9835ee4773627412e0511b72 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 09:36:57 +0000 Subject: [PATCH 007/161] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ------ .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 106 +- benchmark/benchmark.js | 82 - bin/cli | 88 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 50 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 131 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 166 -- 42 files changed, 2710 insertions(+), 4011 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 18231f8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:05:41.968Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 128c22e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,681 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs 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 or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -124,78 +117,7 @@ console.log( codePointAt( '🌷', 1, true ) ); -* * * - -
- -## CLI - -
- -## Installation - -To use the module as a general utility, install the module globally - -```bash -npm install -g @stdlib/string-code-point-at -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] [] --pos= - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -228,7 +150,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -298,7 +220,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d6fa37c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var x; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu() * UNICODE_MAX ); - out = codePointAt( fromCodePoint( x ), 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var x; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu() * UNICODE_MAX ); - out = String.prototype.codePointAt.call( fromCodePoint( x ), 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index cd15ed7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ca79247..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. - - backward: boolean (optional) - Backward iteration for low surrogates. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 493a2cd..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The function does not compile if provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - codePointAt(); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7f67b39..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] [] --pos= - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..758bae1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,n,o){var d,a,m,h;if(!i(s))throw new TypeError(r("0h83N",s));if(!t(n))throw new TypeError(r("invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.",n));if(n>=s.length)throw new RangeError(r("invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.",n));if(arguments.length>2){if(!e(o))throw new TypeError(r("0h8B3",o));a=o}else a=!1;return(d=s.charCodeAt(n))>=55296&&d<=56319&&n=56320&&d<=57343&&n>=1?(m=d,55296<=(h=s.charCodeAt(n-1))&&h<=56319?1024*(h-55296)+(m-56320)+65536:m):d}export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7514aaf --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\n// Factors for converting individual surrogates\nvar Ox10000 = 0x10000|0; // 65536\nvar Ox400 = 0x400|0; // 1024\n\n// Range for a high surrogate\nvar OxD800 = 0xD800|0; // 55296\nvar OxDBFF = 0xDBFF|0; // 56319\n\n// Range for a low surrogate\nvar OxDC00 = 0xDC00|0; // 56320\nvar OxDFFF = 0xDFFF|0; // 57343\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* ## Notes\n*\n* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF).\n* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate.\n*\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a number having a nonnegative integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar code;\n\tvar FLG;\n\tvar low;\n\tvar hi;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83N', str ) );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\tcode = str.charCodeAt( idx );\n\n\t// High surrogate\n\tif ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) {\n\t\thi = code;\n\t\tlow = str.charCodeAt( idx+1 );\n\t\tif ( OxDC00 <= low && low <= OxDFFF ) {\n\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t}\n\t\treturn hi;\n\t}\n\t// Low surrogate - support only if backward iteration is desired\n\tif ( FLG ) {\n\t\tif ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) {\n\t\t\thi = str.charCodeAt( idx-1 );\n\t\t\tlow = code;\n\t\t\tif ( OxD800 <= hi && hi <= OxDBFF ) {\n\t\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t\t}\n\t\t\treturn low;\n\t\t}\n\t}\n\treturn code;\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","code","FLG","low","hi","isString","TypeError","format","isNonNegativeInteger","length","RangeError","arguments","isBoolean","charCodeAt"],"mappings":";;iZA+EA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAUP,GACf,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMU,EAAsBT,GAC3B,MAAM,IAAIO,UAAWC,EAAQ,8FAA+FR,IAE7H,GAAKA,GAAOD,EAAIW,OACf,MAAM,IAAIC,WAAYH,EAAQ,6FAA8FR,IAE7H,GAAKY,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvCE,EAAMF,OAENE,GAAM,EAKP,OAHAD,EAAOH,EAAIe,WAAYd,KAnEX,OAsEWE,GArEX,OAqE6BF,EAAMD,EAAIW,OAAS,GAC3DL,EAAKH,EAnEM,QAoEXE,EAAML,EAAIe,WAAYd,EAAI,KACJI,GApEX,MARD,MA6EEC,EA1ED,QA0E6BD,EAtE7B,OARC,MAgFLC,GAGHF,GACCD,GA5EM,OA4EYA,GA3EZ,OA2E8BF,GAAO,GAE/CI,EAAMF,EAlFI,QAiFVG,EAAKN,EAAIe,WAAYd,EAAI,KAEJK,GAlFX,MAJD,MAuFGA,EApFF,QAoF8BD,EAhF9B,OARC,MA0FJA,GAGFF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8a587be..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var codePointAt = require( './main.js' ); - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index df8c1c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -// Factors for converting individual surrogates -var Ox10000 = 0x10000|0; // 65536 -var Ox400 = 0x400|0; // 1024 - -// Range for a high surrogate -var OxD800 = 0xD800|0; // 55296 -var OxDBFF = 0xDBFF|0; // 56319 - -// Range for a low surrogate -var OxDC00 = 0xDC00|0; // 56320 -var OxDFFF = 0xDFFF|0; // 57343 - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* ## Notes -* -* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF). -* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate. -* -* -* @param {string} str - input string -* @param {NonNegativeInteger} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be a number having a nonnegative integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var code; - var FLG; - var low; - var hi; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83N', str ) ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) ); - } - if ( idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - code = str.charCodeAt( idx ); - - // High surrogate - if ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) { - hi = code; - low = str.charCodeAt( idx+1 ); - if ( OxDC00 <= low && low <= OxDFFF ) { - return ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000; - } - return hi; - } - // Low surrogate - support only if backward iteration is desired - if ( FLG ) { - if ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) { - hi = str.charCodeAt( idx-1 ); - low = code; - if ( OxD800 <= hi && hi <= OxDBFF ) { - return ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000; - } - return low; - } - } - return code; -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index dc9d01d..257c730 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.8", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/cli-ctor": "^0.0.x", - "@stdlib/fs-read-file": "^0.0.x", - "@stdlib/process-read-stdin": "^0.0.x", - "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-windows": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/constants-unicode-max": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/process-exec-path": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-from-code-point": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..08647d8 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index 6262e9c..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 979b719..0000000 --- a/test/test.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string primitive', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean primitive', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'string', 7 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 83b2fda0f09cc6194022b76a7732de420fec74d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 4 Jul 2022 14:45:25 +0000 Subject: [PATCH 008/161] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 90d3bcc..df8c1c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -84,7 +84,7 @@ function codePointAt( str, idx, backward ) { var hi; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83N', str ) ); } if ( !isNonNegativeInteger( idx ) ) { throw new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) ); @@ -94,7 +94,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index f5727ca..dc9d01d 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/fs-read-file": "^0.0.x", "@stdlib/process-read-stdin": "^0.0.x", "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", From 49af23f3048dfcd83880d1ce4027bb2064138015 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 4 Jul 2022 15:28:26 +0000 Subject: [PATCH 009/161] Remove files --- index.d.ts | 45 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2739 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 1fc6118..0000000 --- a/index.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws first argument must be a string -* @throws second argument must be a nonnegative integer -* @throws third argument must be a boolean -* @throws position must be a valid index in string -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 758bae1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,n,o){var d,a,m,h;if(!i(s))throw new TypeError(r("0h83N",s));if(!t(n))throw new TypeError(r("invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.",n));if(n>=s.length)throw new RangeError(r("invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.",n));if(arguments.length>2){if(!e(o))throw new TypeError(r("0h8B3",o));a=o}else a=!1;return(d=s.charCodeAt(n))>=55296&&d<=56319&&n=56320&&d<=57343&&n>=1?(m=d,55296<=(h=s.charCodeAt(n-1))&&h<=56319?1024*(h-55296)+(m-56320)+65536:m):d}export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7514aaf..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\n// Factors for converting individual surrogates\nvar Ox10000 = 0x10000|0; // 65536\nvar Ox400 = 0x400|0; // 1024\n\n// Range for a high surrogate\nvar OxD800 = 0xD800|0; // 55296\nvar OxDBFF = 0xDBFF|0; // 56319\n\n// Range for a low surrogate\nvar OxDC00 = 0xDC00|0; // 56320\nvar OxDFFF = 0xDFFF|0; // 57343\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* ## Notes\n*\n* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF).\n* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate.\n*\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a number having a nonnegative integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar code;\n\tvar FLG;\n\tvar low;\n\tvar hi;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83N', str ) );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\tcode = str.charCodeAt( idx );\n\n\t// High surrogate\n\tif ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) {\n\t\thi = code;\n\t\tlow = str.charCodeAt( idx+1 );\n\t\tif ( OxDC00 <= low && low <= OxDFFF ) {\n\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t}\n\t\treturn hi;\n\t}\n\t// Low surrogate - support only if backward iteration is desired\n\tif ( FLG ) {\n\t\tif ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) {\n\t\t\thi = str.charCodeAt( idx-1 );\n\t\t\tlow = code;\n\t\t\tif ( OxD800 <= hi && hi <= OxDBFF ) {\n\t\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t\t}\n\t\t\treturn low;\n\t\t}\n\t}\n\treturn code;\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","code","FLG","low","hi","isString","TypeError","format","isNonNegativeInteger","length","RangeError","arguments","isBoolean","charCodeAt"],"mappings":";;iZA+EA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAUP,GACf,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMU,EAAsBT,GAC3B,MAAM,IAAIO,UAAWC,EAAQ,8FAA+FR,IAE7H,GAAKA,GAAOD,EAAIW,OACf,MAAM,IAAIC,WAAYH,EAAQ,6FAA8FR,IAE7H,GAAKY,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvCE,EAAMF,OAENE,GAAM,EAKP,OAHAD,EAAOH,EAAIe,WAAYd,KAnEX,OAsEWE,GArEX,OAqE6BF,EAAMD,EAAIW,OAAS,GAC3DL,EAAKH,EAnEM,QAoEXE,EAAML,EAAIe,WAAYd,EAAI,KACJI,GApEX,MARD,MA6EEC,EA1ED,QA0E6BD,EAtE7B,OARC,MAgFLC,GAGHF,GACCD,GA5EM,OA4EYA,GA3EZ,OA2E8BF,GAAO,GAE/CI,EAAMF,EAlFI,QAiFVG,EAAKN,EAAIe,WAAYd,EAAI,KAEJK,GAlFX,MAJD,MAuFGA,EApFF,QAoF8BD,EAhF9B,OARC,MA0FJA,GAGFF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 08647d8..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From ac2f80cc3c8fbc4233f8e05fdc2c5c4048031e2a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 4 Jul 2022 15:29:25 +0000 Subject: [PATCH 010/161] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 687 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 106 +- benchmark/benchmark.js | 82 - bin/cli | 88 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 50 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 131 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 166 -- 41 files changed, 2710 insertions(+), 3976 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 6726965..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,687 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -124,78 +117,7 @@ console.log( codePointAt( '🌷', 1, true ) ); -* * * - -
- -## CLI - -
- -## Installation - -To use the module as a general utility, install the module globally - -```bash -npm install -g @stdlib/string-code-point-at -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] [] --pos= - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -228,7 +150,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -298,7 +220,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d6fa37c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var x; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu() * UNICODE_MAX ); - out = codePointAt( fromCodePoint( x ), 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var x; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu() * UNICODE_MAX ); - out = String.prototype.codePointAt.call( fromCodePoint( x ), 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index cd15ed7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ca79247..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. - - backward: boolean (optional) - Backward iteration for low surrogates. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 493a2cd..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The function does not compile if provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - codePointAt(); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7f67b39..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] [] --pos= - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..758bae1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,n,o){var d,a,m,h;if(!i(s))throw new TypeError(r("0h83N",s));if(!t(n))throw new TypeError(r("invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.",n));if(n>=s.length)throw new RangeError(r("invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.",n));if(arguments.length>2){if(!e(o))throw new TypeError(r("0h8B3",o));a=o}else a=!1;return(d=s.charCodeAt(n))>=55296&&d<=56319&&n=56320&&d<=57343&&n>=1?(m=d,55296<=(h=s.charCodeAt(n-1))&&h<=56319?1024*(h-55296)+(m-56320)+65536:m):d}export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7514aaf --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\n// Factors for converting individual surrogates\nvar Ox10000 = 0x10000|0; // 65536\nvar Ox400 = 0x400|0; // 1024\n\n// Range for a high surrogate\nvar OxD800 = 0xD800|0; // 55296\nvar OxDBFF = 0xDBFF|0; // 56319\n\n// Range for a low surrogate\nvar OxDC00 = 0xDC00|0; // 56320\nvar OxDFFF = 0xDFFF|0; // 57343\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* ## Notes\n*\n* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF).\n* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate.\n*\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a number having a nonnegative integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar code;\n\tvar FLG;\n\tvar low;\n\tvar hi;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83N', str ) );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\tcode = str.charCodeAt( idx );\n\n\t// High surrogate\n\tif ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) {\n\t\thi = code;\n\t\tlow = str.charCodeAt( idx+1 );\n\t\tif ( OxDC00 <= low && low <= OxDFFF ) {\n\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t}\n\t\treturn hi;\n\t}\n\t// Low surrogate - support only if backward iteration is desired\n\tif ( FLG ) {\n\t\tif ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) {\n\t\t\thi = str.charCodeAt( idx-1 );\n\t\t\tlow = code;\n\t\t\tif ( OxD800 <= hi && hi <= OxDBFF ) {\n\t\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t\t}\n\t\t\treturn low;\n\t\t}\n\t}\n\treturn code;\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","code","FLG","low","hi","isString","TypeError","format","isNonNegativeInteger","length","RangeError","arguments","isBoolean","charCodeAt"],"mappings":";;iZA+EA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAUP,GACf,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMU,EAAsBT,GAC3B,MAAM,IAAIO,UAAWC,EAAQ,8FAA+FR,IAE7H,GAAKA,GAAOD,EAAIW,OACf,MAAM,IAAIC,WAAYH,EAAQ,6FAA8FR,IAE7H,GAAKY,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvCE,EAAMF,OAENE,GAAM,EAKP,OAHAD,EAAOH,EAAIe,WAAYd,KAnEX,OAsEWE,GArEX,OAqE6BF,EAAMD,EAAIW,OAAS,GAC3DL,EAAKH,EAnEM,QAoEXE,EAAML,EAAIe,WAAYd,EAAI,KACJI,GApEX,MARD,MA6EEC,EA1ED,QA0E6BD,EAtE7B,OARC,MAgFLC,GAGHF,GACCD,GA5EM,OA4EYA,GA3EZ,OA2E8BF,GAAO,GAE/CI,EAAMF,EAlFI,QAiFVG,EAAKN,EAAIe,WAAYd,EAAI,KAEJK,GAlFX,MAJD,MAuFGA,EApFF,QAoF8BD,EAhF9B,OARC,MA0FJA,GAGFF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8a587be..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var codePointAt = require( './main.js' ); - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index df8c1c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -// Factors for converting individual surrogates -var Ox10000 = 0x10000|0; // 65536 -var Ox400 = 0x400|0; // 1024 - -// Range for a high surrogate -var OxD800 = 0xD800|0; // 55296 -var OxDBFF = 0xDBFF|0; // 56319 - -// Range for a low surrogate -var OxDC00 = 0xDC00|0; // 56320 -var OxDFFF = 0xDFFF|0; // 57343 - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* ## Notes -* -* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF). -* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate. -* -* -* @param {string} str - input string -* @param {NonNegativeInteger} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be a number having a nonnegative integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var code; - var FLG; - var low; - var hi; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83N', str ) ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) ); - } - if ( idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - code = str.charCodeAt( idx ); - - // High surrogate - if ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) { - hi = code; - low = str.charCodeAt( idx+1 ); - if ( OxDC00 <= low && low <= OxDFFF ) { - return ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000; - } - return hi; - } - // Low surrogate - support only if backward iteration is desired - if ( FLG ) { - if ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) { - hi = str.charCodeAt( idx-1 ); - low = code; - if ( OxD800 <= hi && hi <= OxDBFF ) { - return ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000; - } - return low; - } - } - return code; -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index dc9d01d..257c730 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.8", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/cli-ctor": "^0.0.x", - "@stdlib/fs-read-file": "^0.0.x", - "@stdlib/process-read-stdin": "^0.0.x", - "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-windows": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/constants-unicode-max": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/process-exec-path": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-from-code-point": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..293a0b6 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index 6262e9c..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 979b719..0000000 --- a/test/test.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string primitive', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean primitive', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'string', 7 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From efa11c083feb936e0402f031a60e15050ad68af6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 12 Jul 2022 14:26:25 +0000 Subject: [PATCH 011/161] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 90d3bcc..df8c1c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -84,7 +84,7 @@ function codePointAt( str, idx, backward ) { var hi; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83N', str ) ); } if ( !isNonNegativeInteger( idx ) ) { throw new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) ); @@ -94,7 +94,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 5425b81..590ca48 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/fs-read-file": "^0.0.x", "@stdlib/process-read-stdin": "^0.0.x", "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", From e907fa6d24cd175382247639b47267b6717d4c97 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 12 Jul 2022 14:52:48 +0000 Subject: [PATCH 012/161] Remove files --- index.d.ts | 45 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2739 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 1fc6118..0000000 --- a/index.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws first argument must be a string -* @throws second argument must be a nonnegative integer -* @throws third argument must be a boolean -* @throws position must be a valid index in string -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 758bae1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,n,o){var d,a,m,h;if(!i(s))throw new TypeError(r("0h83N",s));if(!t(n))throw new TypeError(r("invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.",n));if(n>=s.length)throw new RangeError(r("invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.",n));if(arguments.length>2){if(!e(o))throw new TypeError(r("0h8B3",o));a=o}else a=!1;return(d=s.charCodeAt(n))>=55296&&d<=56319&&n=56320&&d<=57343&&n>=1?(m=d,55296<=(h=s.charCodeAt(n-1))&&h<=56319?1024*(h-55296)+(m-56320)+65536:m):d}export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7514aaf..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\n// Factors for converting individual surrogates\nvar Ox10000 = 0x10000|0; // 65536\nvar Ox400 = 0x400|0; // 1024\n\n// Range for a high surrogate\nvar OxD800 = 0xD800|0; // 55296\nvar OxDBFF = 0xDBFF|0; // 56319\n\n// Range for a low surrogate\nvar OxDC00 = 0xDC00|0; // 56320\nvar OxDFFF = 0xDFFF|0; // 57343\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* ## Notes\n*\n* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF).\n* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate.\n*\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a number having a nonnegative integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar code;\n\tvar FLG;\n\tvar low;\n\tvar hi;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83N', str ) );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\tcode = str.charCodeAt( idx );\n\n\t// High surrogate\n\tif ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) {\n\t\thi = code;\n\t\tlow = str.charCodeAt( idx+1 );\n\t\tif ( OxDC00 <= low && low <= OxDFFF ) {\n\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t}\n\t\treturn hi;\n\t}\n\t// Low surrogate - support only if backward iteration is desired\n\tif ( FLG ) {\n\t\tif ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) {\n\t\t\thi = str.charCodeAt( idx-1 );\n\t\t\tlow = code;\n\t\t\tif ( OxD800 <= hi && hi <= OxDBFF ) {\n\t\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t\t}\n\t\t\treturn low;\n\t\t}\n\t}\n\treturn code;\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","code","FLG","low","hi","isString","TypeError","format","isNonNegativeInteger","length","RangeError","arguments","isBoolean","charCodeAt"],"mappings":";;iZA+EA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAUP,GACf,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMU,EAAsBT,GAC3B,MAAM,IAAIO,UAAWC,EAAQ,8FAA+FR,IAE7H,GAAKA,GAAOD,EAAIW,OACf,MAAM,IAAIC,WAAYH,EAAQ,6FAA8FR,IAE7H,GAAKY,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvCE,EAAMF,OAENE,GAAM,EAKP,OAHAD,EAAOH,EAAIe,WAAYd,KAnEX,OAsEWE,GArEX,OAqE6BF,EAAMD,EAAIW,OAAS,GAC3DL,EAAKH,EAnEM,QAoEXE,EAAML,EAAIe,WAAYd,EAAI,KACJI,GApEX,MARD,MA6EEC,EA1ED,QA0E6BD,EAtE7B,OARC,MAgFLC,GAGHF,GACCD,GA5EM,OA4EYA,GA3EZ,OA2E8BF,GAAO,GAE/CI,EAAMF,EAlFI,QAiFVG,EAAKN,EAAIe,WAAYd,EAAI,KAEJK,GAlFX,MAJD,MAuFGA,EApFF,QAoF8BD,EAhF9B,OARC,MA0FJA,GAGFF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 293a0b6..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 20f0ecaf5862b287d8288c29e1551e9ef32ddb43 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 12 Jul 2022 14:53:49 +0000 Subject: [PATCH 013/161] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/bundle_tags.yml | 125 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 691 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 106 +- benchmark/benchmark.js | 82 - bin/cli | 88 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 50 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 131 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 166 -- 42 files changed, 2710 insertions(+), 4105 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/bundle_tags.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/bundle_tags.yml b/.github/workflows/bundle_tags.yml deleted file mode 100644 index 46a96ae..0000000 --- a/.github/workflows/bundle_tags.yml +++ /dev/null @@ -1,125 +0,0 @@ - -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: bundle_tags - -# Workflow triggers: -on: - # Run workflow when a new tag is pushed to the repository: - push: - tags: - - '*' - -# Workflow jobs: -jobs: - - # Define job to wait a minute before running the workflow... - waiting: - - # Define display name: - name: 'Waiting Period' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the steps to run: - steps: - - # Wait three minutes: - - name: 'Wait three minutes' - run: | - sleep 3m - - # Define job to publish bundle tags to GitHub... - create-tags: - - # Define display name: - name: 'Create bundle tags' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: waiting - - # Define the steps to run: - steps: - - # Wait for the productionize workflow to succeed: - - name: 'Wait for productionize workflow to succeed' - uses: lewagon/wait-on-check-action@v1.0.0 - timeout-minutes: 5 - with: - ref: main - check-regexp: 'Productionize' - repo-token: ${{ secrets.GITHUB_TOKEN }} - wait-interval: 60 - allowed-conclusions: success - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - git fetch --all - - # Create bundle tags: - - name: 'Create bundle tags' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - ESCAPED=$(echo $SLUG | sed -E 's/\//\\\//g') - - git checkout -b deno origin/deno - sed -i -E "s/$ESCAPED@deno/$ESCAPED@$VERSION-deno/g" README.md - git add README.md - git commit -m "Update README.md for Deno bundle $VERSION" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - sed -i -E "s/$ESCAPED@$VERSION-deno/$ESCAPED@deno/g" README.md - git add README.md - git commit -m "Revert changes to README.md for Deno bundle $VERSION" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - git checkout -b umd origin/umd - sed -i -E "s/$ESCAPED@umd/$ESCAPED@$VERSION-umd/g" README.md - git add README.md - git commit -m "Update README.md for UMD bundle $VERSION" - git tag -a $VERSION-umd -m "$VERSION-umd" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-umd - sed -i -E "s/$ESCAPED@$VERSION-umd/$ESCAPED@umd/g" README.md - git add README.md - git commit -m "Revert changes to README.md for UMD bundle $VERSION" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" umd - - git checkout -b esm origin/esm - sed -i -E "s/$ESCAPED@esm/$ESCAPED@$VERSION-esm/g" README.md - git add README.md - git commit -m "Update README.md for ESM bundle $VERSION" - git tag -a $VERSION-esm -m "$VERSION-esm" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-esm - sed -i -E "s/$ESCAPED@$VERSION-esm/$ESCAPED@esm/g" README.md - git add README.md - git commit -m "Revert changes to README.md for ESM bundle $VERSION" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" esm diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 0a144b2..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,691 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -124,78 +117,7 @@ console.log( codePointAt( '🌷', 1, true ) ); -* * * - -
- -## CLI - -
- -## Installation - -To use the module as a general utility, install the module globally - -```bash -npm install -g @stdlib/string-code-point-at -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] [] --pos= - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -228,7 +150,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -298,7 +220,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d6fa37c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var x; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu() * UNICODE_MAX ); - out = codePointAt( fromCodePoint( x ), 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var x; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu() * UNICODE_MAX ); - out = String.prototype.codePointAt.call( fromCodePoint( x ), 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index cd15ed7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ca79247..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. - - backward: boolean (optional) - Backward iteration for low surrogates. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 493a2cd..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The function does not compile if provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - codePointAt(); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7f67b39..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] [] --pos= - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ede820d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,n,o){var d,a,m,h;if(!i(s))throw new TypeError(r("0h83N",s));if(!t(n))throw new TypeError(r("invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.",n));if(n>=s.length)throw new RangeError(r("invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.",n));if(arguments.length>2){if(!e(o))throw new TypeError(r("0h8B3",o));a=o}else a=!1;return(d=s.charCodeAt(n))>=55296&&d<=56319&&n=56320&&d<=57343&&n>=1?(m=d,55296<=(h=s.charCodeAt(n-1))&&h<=56319?1024*(h-55296)+(m-56320)+65536:m):d}export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..2599212 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\n// Factors for converting individual surrogates\nvar Ox10000 = 0x10000|0; // 65536\nvar Ox400 = 0x400|0; // 1024\n\n// Range for a high surrogate\nvar OxD800 = 0xD800|0; // 55296\nvar OxDBFF = 0xDBFF|0; // 56319\n\n// Range for a low surrogate\nvar OxDC00 = 0xDC00|0; // 56320\nvar OxDFFF = 0xDFFF|0; // 57343\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* ## Notes\n*\n* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF).\n* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate.\n*\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a number having a nonnegative integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar code;\n\tvar FLG;\n\tvar low;\n\tvar hi;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83N', str ) );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\tcode = str.charCodeAt( idx );\n\n\t// High surrogate\n\tif ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) {\n\t\thi = code;\n\t\tlow = str.charCodeAt( idx+1 );\n\t\tif ( OxDC00 <= low && low <= OxDFFF ) {\n\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t}\n\t\treturn hi;\n\t}\n\t// Low surrogate - support only if backward iteration is desired\n\tif ( FLG ) {\n\t\tif ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) {\n\t\t\thi = str.charCodeAt( idx-1 );\n\t\t\tlow = code;\n\t\t\tif ( OxD800 <= hi && hi <= OxDBFF ) {\n\t\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t\t}\n\t\t\treturn low;\n\t\t}\n\t}\n\treturn code;\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","code","FLG","low","hi","isString","TypeError","format","isNonNegativeInteger","length","RangeError","arguments","isBoolean","charCodeAt"],"mappings":";;wZA+EA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAUP,GACf,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMU,EAAsBT,GAC3B,MAAM,IAAIO,UAAWC,EAAQ,8FAA+FR,IAE7H,GAAKA,GAAOD,EAAIW,OACf,MAAM,IAAIC,WAAYH,EAAQ,6FAA8FR,IAE7H,GAAKY,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvCE,EAAMF,OAENE,GAAM,EAKP,OAHAD,EAAOH,EAAIe,WAAYd,KAnEX,OAsEWE,GArEX,OAqE6BF,EAAMD,EAAIW,OAAS,GAC3DL,EAAKH,EAnEM,QAoEXE,EAAML,EAAIe,WAAYd,EAAI,KACJI,GApEX,MARD,MA6EEC,EA1ED,QA0E6BD,EAtE7B,OARC,MAgFLC,GAGHF,GACCD,GA5EM,OA4EYA,GA3EZ,OA2E8BF,GAAO,GAE/CI,EAAMF,EAlFI,QAiFVG,EAAKN,EAAIe,WAAYd,EAAI,KAEJK,GAlFX,MAJD,MAuFGA,EApFF,QAoF8BD,EAhF9B,OARC,MA0FJA,GAGFF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8a587be..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var codePointAt = require( './main.js' ); - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index df8c1c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -// Factors for converting individual surrogates -var Ox10000 = 0x10000|0; // 65536 -var Ox400 = 0x400|0; // 1024 - -// Range for a high surrogate -var OxD800 = 0xD800|0; // 55296 -var OxDBFF = 0xDBFF|0; // 56319 - -// Range for a low surrogate -var OxDC00 = 0xDC00|0; // 56320 -var OxDFFF = 0xDFFF|0; // 57343 - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* ## Notes -* -* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF). -* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate. -* -* -* @param {string} str - input string -* @param {NonNegativeInteger} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be a number having a nonnegative integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var code; - var FLG; - var low; - var hi; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83N', str ) ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) ); - } - if ( idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - code = str.charCodeAt( idx ); - - // High surrogate - if ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) { - hi = code; - low = str.charCodeAt( idx+1 ); - if ( OxDC00 <= low && low <= OxDFFF ) { - return ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000; - } - return hi; - } - // Low surrogate - support only if backward iteration is desired - if ( FLG ) { - if ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) { - hi = str.charCodeAt( idx-1 ); - low = code; - if ( OxD800 <= hi && hi <= OxDBFF ) { - return ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000; - } - return low; - } - } - return code; -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 590ca48..fa3555c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/cli-ctor": "^0.0.x", - "@stdlib/fs-read-file": "^0.0.x", - "@stdlib/process-read-stdin": "^0.0.x", - "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-windows": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/constants-unicode-max": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/process-exec-path": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-from-code-point": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2df6b9e --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index 6262e9c..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 979b719..0000000 --- a/test/test.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string primitive', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean primitive', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'string', 7 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 7da5835a63b7e82746b51233c8e9c8c98acd197b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 04:42:20 +0000 Subject: [PATCH 014/161] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 90d3bcc..df8c1c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -84,7 +84,7 @@ function codePointAt( str, idx, backward ) { var hi; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83N', str ) ); } if ( !isNonNegativeInteger( idx ) ) { throw new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) ); @@ -94,7 +94,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 5425b81..590ca48 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/fs-read-file": "^0.0.x", "@stdlib/process-read-stdin": "^0.0.x", "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", From 3fc62d795d8195787e224c8d3a3693bdd1fae216 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 19:47:04 +0000 Subject: [PATCH 015/161] Remove files --- index.d.ts | 45 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2739 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 1fc6118..0000000 --- a/index.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws first argument must be a string -* @throws second argument must be a nonnegative integer -* @throws third argument must be a boolean -* @throws position must be a valid index in string -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ede820d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,n,o){var d,a,m,h;if(!i(s))throw new TypeError(r("0h83N",s));if(!t(n))throw new TypeError(r("invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.",n));if(n>=s.length)throw new RangeError(r("invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.",n));if(arguments.length>2){if(!e(o))throw new TypeError(r("0h8B3",o));a=o}else a=!1;return(d=s.charCodeAt(n))>=55296&&d<=56319&&n=56320&&d<=57343&&n>=1?(m=d,55296<=(h=s.charCodeAt(n-1))&&h<=56319?1024*(h-55296)+(m-56320)+65536:m):d}export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 2599212..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\n// Factors for converting individual surrogates\nvar Ox10000 = 0x10000|0; // 65536\nvar Ox400 = 0x400|0; // 1024\n\n// Range for a high surrogate\nvar OxD800 = 0xD800|0; // 55296\nvar OxDBFF = 0xDBFF|0; // 56319\n\n// Range for a low surrogate\nvar OxDC00 = 0xDC00|0; // 56320\nvar OxDFFF = 0xDFFF|0; // 57343\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* ## Notes\n*\n* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF).\n* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate.\n*\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a number having a nonnegative integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar code;\n\tvar FLG;\n\tvar low;\n\tvar hi;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83N', str ) );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\tcode = str.charCodeAt( idx );\n\n\t// High surrogate\n\tif ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) {\n\t\thi = code;\n\t\tlow = str.charCodeAt( idx+1 );\n\t\tif ( OxDC00 <= low && low <= OxDFFF ) {\n\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t}\n\t\treturn hi;\n\t}\n\t// Low surrogate - support only if backward iteration is desired\n\tif ( FLG ) {\n\t\tif ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) {\n\t\t\thi = str.charCodeAt( idx-1 );\n\t\t\tlow = code;\n\t\t\tif ( OxD800 <= hi && hi <= OxDBFF ) {\n\t\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t\t}\n\t\t\treturn low;\n\t\t}\n\t}\n\treturn code;\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","code","FLG","low","hi","isString","TypeError","format","isNonNegativeInteger","length","RangeError","arguments","isBoolean","charCodeAt"],"mappings":";;wZA+EA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAUP,GACf,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMU,EAAsBT,GAC3B,MAAM,IAAIO,UAAWC,EAAQ,8FAA+FR,IAE7H,GAAKA,GAAOD,EAAIW,OACf,MAAM,IAAIC,WAAYH,EAAQ,6FAA8FR,IAE7H,GAAKY,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvCE,EAAMF,OAENE,GAAM,EAKP,OAHAD,EAAOH,EAAIe,WAAYd,KAnEX,OAsEWE,GArEX,OAqE6BF,EAAMD,EAAIW,OAAS,GAC3DL,EAAKH,EAnEM,QAoEXE,EAAML,EAAIe,WAAYd,EAAI,KACJI,GApEX,MARD,MA6EEC,EA1ED,QA0E6BD,EAtE7B,OARC,MAgFLC,GAGHF,GACCD,GA5EM,OA4EYA,GA3EZ,OA2E8BF,GAAO,GAE/CI,EAAMF,EAlFI,QAiFVG,EAAKN,EAAIe,WAAYd,EAAI,KAEJK,GAlFX,MAJD,MAuFGA,EApFF,QAoF8BD,EAhF9B,OARC,MA0FJA,GAGFF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2df6b9e..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 4058122f66942fd2804d5ae886cdcd4cffe0d45a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 19:48:07 +0000 Subject: [PATCH 016/161] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 106 +- benchmark/benchmark.js | 82 - bin/cli | 88 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 50 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 131 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 166 -- 42 files changed, 2710 insertions(+), 4050 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 437bb4e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:08:56.184Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -124,78 +117,7 @@ console.log( codePointAt( '🌷', 1, true ) ); -* * * - -
- -## CLI - -
- -## Installation - -To use the module as a general utility, install the module globally - -```bash -npm install -g @stdlib/string-code-point-at -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] [] --pos= - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -228,7 +150,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -298,7 +220,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d6fa37c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var x; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu() * UNICODE_MAX ); - out = codePointAt( fromCodePoint( x ), 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var x; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu() * UNICODE_MAX ); - out = String.prototype.codePointAt.call( fromCodePoint( x ), 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index cd15ed7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ca79247..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. - - backward: boolean (optional) - Backward iteration for low surrogates. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 493a2cd..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The function does not compile if provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - codePointAt(); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7f67b39..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] [] --pos= - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ede820d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,n,o){var d,a,m,h;if(!i(s))throw new TypeError(r("0h83N",s));if(!t(n))throw new TypeError(r("invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.",n));if(n>=s.length)throw new RangeError(r("invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.",n));if(arguments.length>2){if(!e(o))throw new TypeError(r("0h8B3",o));a=o}else a=!1;return(d=s.charCodeAt(n))>=55296&&d<=56319&&n=56320&&d<=57343&&n>=1?(m=d,55296<=(h=s.charCodeAt(n-1))&&h<=56319?1024*(h-55296)+(m-56320)+65536:m):d}export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..2599212 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\n// Factors for converting individual surrogates\nvar Ox10000 = 0x10000|0; // 65536\nvar Ox400 = 0x400|0; // 1024\n\n// Range for a high surrogate\nvar OxD800 = 0xD800|0; // 55296\nvar OxDBFF = 0xDBFF|0; // 56319\n\n// Range for a low surrogate\nvar OxDC00 = 0xDC00|0; // 56320\nvar OxDFFF = 0xDFFF|0; // 57343\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* ## Notes\n*\n* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF).\n* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate.\n*\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a number having a nonnegative integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar code;\n\tvar FLG;\n\tvar low;\n\tvar hi;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83N', str ) );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\tcode = str.charCodeAt( idx );\n\n\t// High surrogate\n\tif ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) {\n\t\thi = code;\n\t\tlow = str.charCodeAt( idx+1 );\n\t\tif ( OxDC00 <= low && low <= OxDFFF ) {\n\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t}\n\t\treturn hi;\n\t}\n\t// Low surrogate - support only if backward iteration is desired\n\tif ( FLG ) {\n\t\tif ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) {\n\t\t\thi = str.charCodeAt( idx-1 );\n\t\t\tlow = code;\n\t\t\tif ( OxD800 <= hi && hi <= OxDBFF ) {\n\t\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t\t}\n\t\t\treturn low;\n\t\t}\n\t}\n\treturn code;\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","code","FLG","low","hi","isString","TypeError","format","isNonNegativeInteger","length","RangeError","arguments","isBoolean","charCodeAt"],"mappings":";;wZA+EA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAUP,GACf,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMU,EAAsBT,GAC3B,MAAM,IAAIO,UAAWC,EAAQ,8FAA+FR,IAE7H,GAAKA,GAAOD,EAAIW,OACf,MAAM,IAAIC,WAAYH,EAAQ,6FAA8FR,IAE7H,GAAKY,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvCE,EAAMF,OAENE,GAAM,EAKP,OAHAD,EAAOH,EAAIe,WAAYd,KAnEX,OAsEWE,GArEX,OAqE6BF,EAAMD,EAAIW,OAAS,GAC3DL,EAAKH,EAnEM,QAoEXE,EAAML,EAAIe,WAAYd,EAAI,KACJI,GApEX,MARD,MA6EEC,EA1ED,QA0E6BD,EAtE7B,OARC,MAgFLC,GAGHF,GACCD,GA5EM,OA4EYA,GA3EZ,OA2E8BF,GAAO,GAE/CI,EAAMF,EAlFI,QAiFVG,EAAKN,EAAIe,WAAYd,EAAI,KAEJK,GAlFX,MAJD,MAuFGA,EApFF,QAoF8BD,EAhF9B,OARC,MA0FJA,GAGFF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8a587be..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var codePointAt = require( './main.js' ); - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index df8c1c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -// Factors for converting individual surrogates -var Ox10000 = 0x10000|0; // 65536 -var Ox400 = 0x400|0; // 1024 - -// Range for a high surrogate -var OxD800 = 0xD800|0; // 55296 -var OxDBFF = 0xDBFF|0; // 56319 - -// Range for a low surrogate -var OxDC00 = 0xDC00|0; // 56320 -var OxDFFF = 0xDFFF|0; // 57343 - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* ## Notes -* -* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF). -* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate. -* -* -* @param {string} str - input string -* @param {NonNegativeInteger} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be a number having a nonnegative integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var code; - var FLG; - var low; - var hi; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83N', str ) ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) ); - } - if ( idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - code = str.charCodeAt( idx ); - - // High surrogate - if ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) { - hi = code; - low = str.charCodeAt( idx+1 ); - if ( OxDC00 <= low && low <= OxDFFF ) { - return ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000; - } - return hi; - } - // Low surrogate - support only if backward iteration is desired - if ( FLG ) { - if ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) { - hi = str.charCodeAt( idx-1 ); - low = code; - if ( OxD800 <= hi && hi <= OxDBFF ) { - return ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000; - } - return low; - } - } - return code; -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 590ca48..fa3555c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/cli-ctor": "^0.0.x", - "@stdlib/fs-read-file": "^0.0.x", - "@stdlib/process-read-stdin": "^0.0.x", - "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-windows": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/constants-unicode-max": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/process-exec-path": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-from-code-point": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8dc86bb --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index 6262e9c..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 979b719..0000000 --- a/test/test.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string primitive', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean primitive', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'string', 7 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 413024ce149ef9cfbaa2efb34ba4ec69cbde7bda Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 04:20:16 +0000 Subject: [PATCH 017/161] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 90d3bcc..df8c1c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -84,7 +84,7 @@ function codePointAt( str, idx, backward ) { var hi; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83N', str ) ); } if ( !isNonNegativeInteger( idx ) ) { throw new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) ); @@ -94,7 +94,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 5425b81..590ca48 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/fs-read-file": "^0.0.x", "@stdlib/process-read-stdin": "^0.0.x", "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", From 5bc16dc64793f122be47bbd72c34a90bc515ff83 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 15:21:04 +0000 Subject: [PATCH 018/161] Remove files --- index.d.ts | 45 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2739 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 1fc6118..0000000 --- a/index.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws first argument must be a string -* @throws second argument must be a nonnegative integer -* @throws third argument must be a boolean -* @throws position must be a valid index in string -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ede820d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,n,o){var d,a,m,h;if(!i(s))throw new TypeError(r("0h83N",s));if(!t(n))throw new TypeError(r("invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.",n));if(n>=s.length)throw new RangeError(r("invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.",n));if(arguments.length>2){if(!e(o))throw new TypeError(r("0h8B3",o));a=o}else a=!1;return(d=s.charCodeAt(n))>=55296&&d<=56319&&n=56320&&d<=57343&&n>=1?(m=d,55296<=(h=s.charCodeAt(n-1))&&h<=56319?1024*(h-55296)+(m-56320)+65536:m):d}export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 2599212..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\n// Factors for converting individual surrogates\nvar Ox10000 = 0x10000|0; // 65536\nvar Ox400 = 0x400|0; // 1024\n\n// Range for a high surrogate\nvar OxD800 = 0xD800|0; // 55296\nvar OxDBFF = 0xDBFF|0; // 56319\n\n// Range for a low surrogate\nvar OxDC00 = 0xDC00|0; // 56320\nvar OxDFFF = 0xDFFF|0; // 57343\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* ## Notes\n*\n* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF).\n* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate.\n*\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a number having a nonnegative integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar code;\n\tvar FLG;\n\tvar low;\n\tvar hi;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83N', str ) );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\tcode = str.charCodeAt( idx );\n\n\t// High surrogate\n\tif ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) {\n\t\thi = code;\n\t\tlow = str.charCodeAt( idx+1 );\n\t\tif ( OxDC00 <= low && low <= OxDFFF ) {\n\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t}\n\t\treturn hi;\n\t}\n\t// Low surrogate - support only if backward iteration is desired\n\tif ( FLG ) {\n\t\tif ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) {\n\t\t\thi = str.charCodeAt( idx-1 );\n\t\t\tlow = code;\n\t\t\tif ( OxD800 <= hi && hi <= OxDBFF ) {\n\t\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t\t}\n\t\t\treturn low;\n\t\t}\n\t}\n\treturn code;\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","code","FLG","low","hi","isString","TypeError","format","isNonNegativeInteger","length","RangeError","arguments","isBoolean","charCodeAt"],"mappings":";;wZA+EA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAUP,GACf,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMU,EAAsBT,GAC3B,MAAM,IAAIO,UAAWC,EAAQ,8FAA+FR,IAE7H,GAAKA,GAAOD,EAAIW,OACf,MAAM,IAAIC,WAAYH,EAAQ,6FAA8FR,IAE7H,GAAKY,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvCE,EAAMF,OAENE,GAAM,EAKP,OAHAD,EAAOH,EAAIe,WAAYd,KAnEX,OAsEWE,GArEX,OAqE6BF,EAAMD,EAAIW,OAAS,GAC3DL,EAAKH,EAnEM,QAoEXE,EAAML,EAAIe,WAAYd,EAAI,KACJI,GApEX,MARD,MA6EEC,EA1ED,QA0E6BD,EAtE7B,OARC,MAgFLC,GAGHF,GACCD,GA5EM,OA4EYA,GA3EZ,OA2E8BF,GAAO,GAE/CI,EAAMF,EAlFI,QAiFVG,EAAKN,EAAIe,WAAYd,EAAI,KAEJK,GAlFX,MAJD,MAuFGA,EApFF,QAoF8BD,EAhF9B,OARC,MA0FJA,GAGFF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8dc86bb..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 056921018cf3c56f43dab5d64927edd656db1cd6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 15:22:06 +0000 Subject: [PATCH 019/161] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 106 +- benchmark/benchmark.js | 82 - bin/cli | 88 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 50 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 131 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 166 -- 42 files changed, 2710 insertions(+), 4066 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 30197cc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:06:26.866Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -124,78 +117,7 @@ console.log( codePointAt( '🌷', 1, true ) ); -* * * - -
- -## CLI - -
- -## Installation - -To use the module as a general utility, install the module globally - -```bash -npm install -g @stdlib/string-code-point-at -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] [] --pos= - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -228,7 +150,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -298,7 +220,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d6fa37c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var x; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu() * UNICODE_MAX ); - out = codePointAt( fromCodePoint( x ), 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var x; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu() * UNICODE_MAX ); - out = String.prototype.codePointAt.call( fromCodePoint( x ), 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index cd15ed7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ca79247..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. - - backward: boolean (optional) - Backward iteration for low surrogates. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 493a2cd..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The function does not compile if provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - codePointAt(); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7f67b39..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] [] --pos= - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ede820d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,n,o){var d,a,m,h;if(!i(s))throw new TypeError(r("0h83N",s));if(!t(n))throw new TypeError(r("invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.",n));if(n>=s.length)throw new RangeError(r("invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.",n));if(arguments.length>2){if(!e(o))throw new TypeError(r("0h8B3",o));a=o}else a=!1;return(d=s.charCodeAt(n))>=55296&&d<=56319&&n=56320&&d<=57343&&n>=1?(m=d,55296<=(h=s.charCodeAt(n-1))&&h<=56319?1024*(h-55296)+(m-56320)+65536:m):d}export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..2599212 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\n// Factors for converting individual surrogates\nvar Ox10000 = 0x10000|0; // 65536\nvar Ox400 = 0x400|0; // 1024\n\n// Range for a high surrogate\nvar OxD800 = 0xD800|0; // 55296\nvar OxDBFF = 0xDBFF|0; // 56319\n\n// Range for a low surrogate\nvar OxDC00 = 0xDC00|0; // 56320\nvar OxDFFF = 0xDFFF|0; // 57343\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* ## Notes\n*\n* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF).\n* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate.\n*\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a number having a nonnegative integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar code;\n\tvar FLG;\n\tvar low;\n\tvar hi;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83N', str ) );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\tcode = str.charCodeAt( idx );\n\n\t// High surrogate\n\tif ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) {\n\t\thi = code;\n\t\tlow = str.charCodeAt( idx+1 );\n\t\tif ( OxDC00 <= low && low <= OxDFFF ) {\n\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t}\n\t\treturn hi;\n\t}\n\t// Low surrogate - support only if backward iteration is desired\n\tif ( FLG ) {\n\t\tif ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) {\n\t\t\thi = str.charCodeAt( idx-1 );\n\t\t\tlow = code;\n\t\t\tif ( OxD800 <= hi && hi <= OxDBFF ) {\n\t\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t\t}\n\t\t\treturn low;\n\t\t}\n\t}\n\treturn code;\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","code","FLG","low","hi","isString","TypeError","format","isNonNegativeInteger","length","RangeError","arguments","isBoolean","charCodeAt"],"mappings":";;wZA+EA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAUP,GACf,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMU,EAAsBT,GAC3B,MAAM,IAAIO,UAAWC,EAAQ,8FAA+FR,IAE7H,GAAKA,GAAOD,EAAIW,OACf,MAAM,IAAIC,WAAYH,EAAQ,6FAA8FR,IAE7H,GAAKY,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvCE,EAAMF,OAENE,GAAM,EAKP,OAHAD,EAAOH,EAAIe,WAAYd,KAnEX,OAsEWE,GArEX,OAqE6BF,EAAMD,EAAIW,OAAS,GAC3DL,EAAKH,EAnEM,QAoEXE,EAAML,EAAIe,WAAYd,EAAI,KACJI,GApEX,MARD,MA6EEC,EA1ED,QA0E6BD,EAtE7B,OARC,MAgFLC,GAGHF,GACCD,GA5EM,OA4EYA,GA3EZ,OA2E8BF,GAAO,GAE/CI,EAAMF,EAlFI,QAiFVG,EAAKN,EAAIe,WAAYd,EAAI,KAEJK,GAlFX,MAJD,MAuFGA,EApFF,QAoF8BD,EAhF9B,OARC,MA0FJA,GAGFF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8a587be..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var codePointAt = require( './main.js' ); - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index df8c1c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -// Factors for converting individual surrogates -var Ox10000 = 0x10000|0; // 65536 -var Ox400 = 0x400|0; // 1024 - -// Range for a high surrogate -var OxD800 = 0xD800|0; // 55296 -var OxDBFF = 0xDBFF|0; // 56319 - -// Range for a low surrogate -var OxDC00 = 0xDC00|0; // 56320 -var OxDFFF = 0xDFFF|0; // 57343 - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* ## Notes -* -* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF). -* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate. -* -* -* @param {string} str - input string -* @param {NonNegativeInteger} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be a number having a nonnegative integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var code; - var FLG; - var low; - var hi; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83N', str ) ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) ); - } - if ( idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - code = str.charCodeAt( idx ); - - // High surrogate - if ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) { - hi = code; - low = str.charCodeAt( idx+1 ); - if ( OxDC00 <= low && low <= OxDFFF ) { - return ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000; - } - return hi; - } - // Low surrogate - support only if backward iteration is desired - if ( FLG ) { - if ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) { - hi = str.charCodeAt( idx-1 ); - low = code; - if ( OxD800 <= hi && hi <= OxDBFF ) { - return ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000; - } - return low; - } - } - return code; -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 590ca48..fa3555c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/cli-ctor": "^0.0.x", - "@stdlib/fs-read-file": "^0.0.x", - "@stdlib/process-read-stdin": "^0.0.x", - "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-windows": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/constants-unicode-max": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/process-exec-path": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-from-code-point": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..277dd7c --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index 6262e9c..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 979b719..0000000 --- a/test/test.js +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string primitive', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean primitive', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'string', 7 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 9500c216616d1ebbfa3568f80e18ee25635f45ba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 02:28:30 +0000 Subject: [PATCH 020/161] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..8da7d24 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,10 +61,10 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83R', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '0h87x', idx ) ); } if ( idx < 0 ) { idx += str.length; @@ -74,7 +74,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index b03fe4a..086576e 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.0.x", "@stdlib/streams-node-stdin": "^0.0.x", "@stdlib/string-base-code-point-at": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", From 71275d951f99e33bdb3371ef9b6c4b8a86c6e972 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 13:57:23 +0000 Subject: [PATCH 021/161] Remove files --- index.d.ts | 45 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2739 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 1fc6118..0000000 --- a/index.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws first argument must be a string -* @throws second argument must be a nonnegative integer -* @throws third argument must be a boolean -* @throws position must be a valid index in string -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ede820d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,n,o){var d,a,m,h;if(!i(s))throw new TypeError(r("0h83N",s));if(!t(n))throw new TypeError(r("invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.",n));if(n>=s.length)throw new RangeError(r("invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.",n));if(arguments.length>2){if(!e(o))throw new TypeError(r("0h8B3",o));a=o}else a=!1;return(d=s.charCodeAt(n))>=55296&&d<=56319&&n=56320&&d<=57343&&n>=1?(m=d,55296<=(h=s.charCodeAt(n-1))&&h<=56319?1024*(h-55296)+(m-56320)+65536:m):d}export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 2599212..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\n// Factors for converting individual surrogates\nvar Ox10000 = 0x10000|0; // 65536\nvar Ox400 = 0x400|0; // 1024\n\n// Range for a high surrogate\nvar OxD800 = 0xD800|0; // 55296\nvar OxDBFF = 0xDBFF|0; // 56319\n\n// Range for a low surrogate\nvar OxDC00 = 0xDC00|0; // 56320\nvar OxDFFF = 0xDFFF|0; // 57343\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* ## Notes\n*\n* - UTF-16 encoding uses one 16-bit unit for non-surrogates (U+0000 to U+D7FF and U+E000 to U+FFFF).\n* - UTF-16 encoding uses two 16-bit units (surrogate pairs) for U+10000 to U+10FFFF and encodes U+10000-U+10FFFF by subtracting 0x10000 from the code point, expressing the result as a 20-bit binary, and splitting the 20 bits of 0x0-0xFFFFF as upper and lower 10-bits. The respective 10-bits are stored in two 16-bit words: a high and a low surrogate.\n*\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a number having a nonnegative integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar code;\n\tvar FLG;\n\tvar low;\n\tvar hi;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83N', str ) );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a valid position (i.e., a nonnegative integer). Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Must provide a valid position (i.e., within string bounds). Value: `%u`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\tcode = str.charCodeAt( idx );\n\n\t// High surrogate\n\tif ( code >= OxD800 && code <= OxDBFF && idx < str.length - 1 ) {\n\t\thi = code;\n\t\tlow = str.charCodeAt( idx+1 );\n\t\tif ( OxDC00 <= low && low <= OxDFFF ) {\n\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t}\n\t\treturn hi;\n\t}\n\t// Low surrogate - support only if backward iteration is desired\n\tif ( FLG ) {\n\t\tif ( code >= OxDC00 && code <= OxDFFF && idx >= 1 ) {\n\t\t\thi = str.charCodeAt( idx-1 );\n\t\t\tlow = code;\n\t\t\tif ( OxD800 <= hi && hi <= OxDBFF ) {\n\t\t\t\treturn ( ( hi - OxD800 ) * Ox400 ) + ( low - OxDC00 ) + Ox10000;\n\t\t\t}\n\t\t\treturn low;\n\t\t}\n\t}\n\treturn code;\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","code","FLG","low","hi","isString","TypeError","format","isNonNegativeInteger","length","RangeError","arguments","isBoolean","charCodeAt"],"mappings":";;wZA+EA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAUP,GACf,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAEvC,IAAMU,EAAsBT,GAC3B,MAAM,IAAIO,UAAWC,EAAQ,8FAA+FR,IAE7H,GAAKA,GAAOD,EAAIW,OACf,MAAM,IAAIC,WAAYH,EAAQ,6FAA8FR,IAE7H,GAAKY,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWZ,GAChB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvCE,EAAMF,OAENE,GAAM,EAKP,OAHAD,EAAOH,EAAIe,WAAYd,KAnEX,OAsEWE,GArEX,OAqE6BF,EAAMD,EAAIW,OAAS,GAC3DL,EAAKH,EAnEM,QAoEXE,EAAML,EAAIe,WAAYd,EAAI,KACJI,GApEX,MARD,MA6EEC,EA1ED,QA0E6BD,EAtE7B,OARC,MAgFLC,GAGHF,GACCD,GA5EM,OA4EYA,GA3EZ,OA2E8BF,GAAO,GAE/CI,EAAMF,EAlFI,QAiFVG,EAAKN,EAAIe,WAAYd,EAAI,KAEJK,GAlFX,MAJD,MAuFGA,EApFF,QAoF8BD,EAhF9B,OARC,MA0FJA,GAGFF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 277dd7c..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From a09f339fbd1b0cb0ba6883c665f5b64eb3562e41 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 13:58:28 +0000 Subject: [PATCH 022/161] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 106 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 53 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 2689 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 181 -- 42 files changed, 2710 insertions(+), 4048 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5cbbb4e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T01:29:48.086Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -133,78 +126,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use the module as a general utility, install the module globally - -```bash -npm install -g @stdlib/string-code-point-at -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -237,7 +159,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -307,7 +229,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index cd15ed7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..74aa969 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7506489 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport base from '@stdlib/string-base-code-point-at' ;\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,OAENC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8da7d24..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83R', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '0h87x', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 086576e..fa3555c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/cli-ctor": "^0.0.x", - "@stdlib/fs-read-file": "^0.0.x", - "@stdlib/process-read-stdin": "^0.0.x", - "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/string-base-code-point-at": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-windows": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/constants-unicode-max": "^0.0.x", - "@stdlib/process-exec-path": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/string-from-code-point": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..296373c --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From c7e6d1ceff57dc7cb63cd93cfd981334b7a2eb9f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:08:49 +0000 Subject: [PATCH 023/161] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..8da7d24 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,10 +61,10 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83R', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '0h87x', idx ) ); } if ( idx < 0 ) { idx += str.length; @@ -74,7 +74,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index b03fe4a..086576e 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.0.x", "@stdlib/streams-node-stdin": "^0.0.x", "@stdlib/string-base-code-point-at": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", From a1090f6eb5e2413cc9ff8c8fedefcdebd97187a1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 12:21:22 +0000 Subject: [PATCH 024/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2737 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 9a429e0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 74aa969..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7506489..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport base from '@stdlib/string-base-code-point-at' ;\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,OAENC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 296373c..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 02573b014b88116d16760e63e7a043fcdcb42477 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 12:22:28 +0000 Subject: [PATCH 025/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 106 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 53 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 4044 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 181 - 42 files changed, 4065 insertions(+), 4048 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 9424b78..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:18:01.015Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4e932aa..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9113bfe..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -133,78 +126,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use the module as a general utility, install the module globally - -```bash -npm install -g @stdlib/string-code-point-at -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -237,7 +159,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -307,7 +229,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index cd15ed7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..74aa969 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8157a5d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport base from '@stdlib/string-base-code-point-at' ;\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8da7d24..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83R', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '0h87x', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 086576e..fa3555c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/cli-ctor": "^0.0.x", - "@stdlib/fs-read-file": "^0.0.x", - "@stdlib/process-read-stdin": "^0.0.x", - "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/string-base-code-point-at": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-windows": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/constants-unicode-max": "^0.0.x", - "@stdlib/process-exec-path": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/string-from-code-point": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ee45ffb --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 267e15dfb0f6c0ab8f4a8d1ea2da633660e16a72 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 3 Nov 2022 22:05:10 +0000 Subject: [PATCH 026/161] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..8da7d24 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,10 +61,10 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83R', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '0h87x', idx ) ); } if ( idx < 0 ) { idx += str.length; @@ -74,7 +74,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index b03fe4a..086576e 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.0.x", "@stdlib/streams-node-stdin": "^0.0.x", "@stdlib/string-base-code-point-at": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", From 7eb788191010d473d9a3c1f726183a799335e3d9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 10:44:30 +0000 Subject: [PATCH 027/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4092 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 9a429e0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 74aa969..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8157a5d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport base from '@stdlib/string-base-code-point-at' ;\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ee45ffb..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 851571a728ab20b502ba7ace4b7a892b88bad8b2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 10:45:28 +0000 Subject: [PATCH 028/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 106 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 53 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 4044 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 181 - 42 files changed, 4065 insertions(+), 4069 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b0eddf6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T21:48:38.898Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4e932aa..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -133,78 +126,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use the module as a general utility, install the module globally - -```bash -npm install -g @stdlib/string-code-point-at -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -237,7 +159,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -307,7 +229,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index cd15ed7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..74aa969 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8157a5d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport base from '@stdlib/string-base-code-point-at' ;\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8da7d24..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83R', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '0h87x', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 086576e..fa3555c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/cli-ctor": "^0.0.x", - "@stdlib/fs-read-file": "^0.0.x", - "@stdlib/process-read-stdin": "^0.0.x", - "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/string-base-code-point-at": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-windows": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/constants-unicode-max": "^0.0.x", - "@stdlib/process-exec-path": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/string-from-code-point": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..75e74c8 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From a9c8e5dce7d68a424c27dd2cbdc1bb670a8bd0a7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 03:53:39 +0000 Subject: [PATCH 029/161] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..8da7d24 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,10 +61,10 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83R', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '0h87x', idx ) ); } if ( idx < 0 ) { idx += str.length; @@ -74,7 +74,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 13e6f60..87448b7 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.0.x", "@stdlib/streams-node-stdin": "^0.0.x", "@stdlib/string-base-code-point-at": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", From 4f12101cd0e8fc192e1e208297dfb71812816916 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 11:17:45 +0000 Subject: [PATCH 030/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4092 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 9a429e0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 74aa969..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8157a5d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport base from '@stdlib/string-base-code-point-at' ;\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 75e74c8..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 1038a112e41eeeae619f1069b0976acc9276be41 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 11:18:33 +0000 Subject: [PATCH 031/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 183 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 106 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 53 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 4044 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 181 - 42 files changed, 4065 insertions(+), 4074 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1463493..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T01:38:32.605Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4e932aa..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -133,78 +126,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use the module as a general utility, install the module globally - -```bash -npm install -g @stdlib/string-code-point-at -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -237,7 +159,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -307,7 +229,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index cd15ed7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..74aa969 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d2af5c2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8da7d24..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83R', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '0h87x', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 87448b7..fa3555c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/cli-ctor": "^0.0.x", - "@stdlib/fs-read-file": "^0.0.x", - "@stdlib/process-read-stdin": "^0.0.x", - "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/string-base-code-point-at": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-windows": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/constants-unicode-max": "^0.0.x", - "@stdlib/process-exec-path": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/string-from-code-point": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "2.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2fce1b6 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From b246d9720b78e83076058f02aa847f1ab1da5b00 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 03:15:45 +0000 Subject: [PATCH 032/161] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..8da7d24 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,10 +61,10 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83R', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '0h87x', idx ) ); } if ( idx < 0 ) { idx += str.length; @@ -74,7 +74,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 8f074ac..130f765 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.0.x", "@stdlib/streams-node-stdin": "^0.0.x", "@stdlib/string-base-code-point-at": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", From 8dc29db7b85c581a8bc491e41eceb4bcc5c9187f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 13:10:59 +0000 Subject: [PATCH 033/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4092 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 9a429e0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 74aa969..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d2af5c2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2fce1b6..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 506c4a70d79ef8297d6c40e71c88f15a15513ade Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 13:11:53 +0000 Subject: [PATCH 034/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 106 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 53 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 4044 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 181 - 42 files changed, 4065 insertions(+), 4085 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1fde1a4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T01:07:45.159Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4e932aa..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -133,78 +126,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use the module as a general utility, install the module globally - -```bash -npm install -g @stdlib/string-code-point-at -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -237,7 +159,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -307,7 +229,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index cd15ed7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cc39401 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d2af5c2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8da7d24..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83R', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '0h87x', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 130f765..fa3555c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/cli-ctor": "^0.0.x", - "@stdlib/fs-read-file": "^0.0.x", - "@stdlib/process-read-stdin": "^0.0.x", - "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/string-base-code-point-at": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-windows": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/constants-unicode-max": "^0.0.x", - "@stdlib/process-exec-path": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/string-from-code-point": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "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", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..673708c --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 7689babd2ea6cc7bac16dfcd2f5b20c32d408fc2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 03:45:20 +0000 Subject: [PATCH 035/161] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..8da7d24 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,10 +61,10 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83R', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '0h87x', idx ) ); } if ( idx < 0 ) { idx += str.length; @@ -74,7 +74,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 8f074ac..130f765 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.0.x", "@stdlib/streams-node-stdin": "^0.0.x", "@stdlib/string-base-code-point-at": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", From 0c179002063a932d21407588fedf7d50ca63d4d7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 11:58:06 +0000 Subject: [PATCH 036/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4092 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 9a429e0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cc39401..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d2af5c2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 673708c..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From d4da4db4ad2ef221e2b2017e9162944c7be1bf75 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 11:58:50 +0000 Subject: [PATCH 037/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 --- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 106 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 53 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 42 files changed, 6198 insertions(+), 4085 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index f271a54..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T01:28:15.875Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4e932aa..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -133,78 +126,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use the module as a general utility, install the module globally - -```bash -npm install -g @stdlib/string-code-point-at -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -237,7 +159,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -307,7 +229,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index cd15ed7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cc39401 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d2af5c2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8da7d24..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83R', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '0h87x', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 130f765..fa3555c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/cli-ctor": "^0.0.x", - "@stdlib/fs-read-file": "^0.0.x", - "@stdlib/process-read-stdin": "^0.0.x", - "@stdlib/streams-node-stdin": "^0.0.x", - "@stdlib/string-base-code-point-at": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-windows": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/constants-unicode-max": "^0.0.x", - "@stdlib/process-exec-path": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/string-from-code-point": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "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", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..820a185 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 541b184a467b10daa1afddb0a2e70c6c833987fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 05:15:05 +0000 Subject: [PATCH 038/161] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..8da7d24 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,10 +61,10 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83R', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '0h87x', idx ) ); } if ( idx < 0 ) { idx += str.length; @@ -74,7 +74,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 564875c..1ed2f32 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.0.7", "@stdlib/streams-node-stdin": "^0.0.7", "@stdlib/string-base-code-point-at": "^0.0.2", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.8", From 9342408ed35c497d011c44219d40a78d76a7b78d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 12:45:52 +0000 Subject: [PATCH 039/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 9a429e0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cc39401..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d2af5c2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 820a185..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 91159821e7aa668f91aa56567288583cd089af26 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 12:46:57 +0000 Subject: [PATCH 040/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 1007 ---- .github/workflows/publish.yml | 236 - .github/workflows/publish_cli.yml | 159 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 107 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 57 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 43 files changed, 6198 insertions(+), 4593 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 44fe1a0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T03:23:03.633Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4e932aa..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 240c5f2..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1007 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -134,78 +126,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -238,7 +159,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -312,7 +233,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6290c61..0000000 --- a/branches.md +++ /dev/null @@ -1,57 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cc39401 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d2af5c2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8da7d24..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83R', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '0h87x', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 1ed2f32..a0499bf 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/cli-ctor": "^0.0.3", - "@stdlib/fs-read-file": "^0.0.8", - "@stdlib/process-read-stdin": "^0.0.7", - "@stdlib/streams-node-stdin": "^0.0.7", - "@stdlib/string-base-code-point-at": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-windows": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/constants-unicode-max": "^0.0.7", - "@stdlib/process-exec-path": "^0.0.7", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@stdlib/string-from-code-point": "^0.0.9", - "@stdlib/string-replace": "^0.0.11", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "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", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2205e83 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From e59e99e1840632e2344d77e59f17c3c74d416af8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 05:41:42 +0000 Subject: [PATCH 041/161] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..8da7d24 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,10 +61,10 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83R', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '0h87x', idx ) ); } if ( idx < 0 ) { idx += str.length; @@ -74,7 +74,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 564875c..1ed2f32 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.0.7", "@stdlib/streams-node-stdin": "^0.0.7", "@stdlib/string-base-code-point-at": "^0.0.2", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.8", From ad2bd73c15d628a7448e028d79b82bd035c6e66c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 12:12:08 +0000 Subject: [PATCH 042/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 9a429e0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cc39401..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d2af5c2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2205e83..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 752e4f01bf00886da52aa6982aa03be7ecd45a71 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 12:12:58 +0000 Subject: [PATCH 043/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 1007 ---- .github/workflows/publish.yml | 242 - .github/workflows/publish_cli.yml | 165 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 107 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 57 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 43 files changed, 6198 insertions(+), 4605 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b0f4e9b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-04-01T03:50:44.637Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4e932aa..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 240c5f2..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1007 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -134,78 +126,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -238,7 +159,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -312,7 +233,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6290c61..0000000 --- a/branches.md +++ /dev/null @@ -1,57 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cc39401 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d2af5c2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8da7d24..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83R', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '0h87x', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 1ed2f32..a0499bf 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/cli-ctor": "^0.0.3", - "@stdlib/fs-read-file": "^0.0.8", - "@stdlib/process-read-stdin": "^0.0.7", - "@stdlib/streams-node-stdin": "^0.0.7", - "@stdlib/string-base-code-point-at": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-windows": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/constants-unicode-max": "^0.0.7", - "@stdlib/process-exec-path": "^0.0.7", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@stdlib/string-from-code-point": "^0.0.9", - "@stdlib/string-replace": "^0.0.11", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "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", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d873338 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 46871947567472b3917a95f8e42f16fc8ee3be92 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 05:29:28 +0000 Subject: [PATCH 044/161] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..8da7d24 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,10 +61,10 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83R', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '0h87x', idx ) ); } if ( idx < 0 ) { idx += str.length; @@ -74,7 +74,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 564875c..1ed2f32 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.0.7", "@stdlib/streams-node-stdin": "^0.0.7", "@stdlib/string-base-code-point-at": "^0.0.2", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.8", From 8cd0925073ab61b72740f2a8251656907e07db26 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 11:56:04 +0000 Subject: [PATCH 045/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 9a429e0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cc39401..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d2af5c2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d873338..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fd5ea8493694cd2a84e0c8c00d5a5638761e9eee Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 11:57:03 +0000 Subject: [PATCH 046/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 1007 ---- .github/workflows/publish.yml | 242 - .github/workflows/publish_cli.yml | 165 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 107 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 57 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 43 files changed, 6198 insertions(+), 4605 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a41091d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-05-01T03:39:32.962Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4e932aa..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 240c5f2..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1007 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -134,78 +126,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -238,7 +159,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -312,7 +233,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6290c61..0000000 --- a/branches.md +++ /dev/null @@ -1,57 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cc39401 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d2af5c2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8da7d24..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83R', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '0h87x', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 1ed2f32..a0499bf 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/cli-ctor": "^0.0.3", - "@stdlib/fs-read-file": "^0.0.8", - "@stdlib/process-read-stdin": "^0.0.7", - "@stdlib/streams-node-stdin": "^0.0.7", - "@stdlib/string-base-code-point-at": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-windows": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/constants-unicode-max": "^0.0.7", - "@stdlib/process-exec-path": "^0.0.7", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@stdlib/string-from-code-point": "^0.0.9", - "@stdlib/string-replace": "^0.0.11", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "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", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9461887 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From e257f0fcaa205b03d6becad528e1cc44cee6ef41 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 05:13:11 +0000 Subject: [PATCH 047/161] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..8da7d24 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,10 +61,10 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83R', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '0h87x', idx ) ); } if ( idx < 0 ) { idx += str.length; @@ -74,7 +74,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 564875c..1ed2f32 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.0.7", "@stdlib/streams-node-stdin": "^0.0.7", "@stdlib/string-base-code-point-at": "^0.0.2", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.8", From 274542f464b457ecb3a717fcec2aae205bb92a50 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 12:22:01 +0000 Subject: [PATCH 048/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 9a429e0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cc39401..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d2af5c2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9461887..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 79efbe10243fa05c28bceec5fe59c9babc4e0748 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 12:22:53 +0000 Subject: [PATCH 049/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 1007 ---- .github/workflows/publish.yml | 242 - .github/workflows/publish_cli.yml | 165 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 107 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 57 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 43 files changed, 6198 insertions(+), 4605 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index f1a9a33..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T03:23:28.907Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4e932aa..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 240c5f2..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1007 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -134,78 +126,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -238,7 +159,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -312,7 +233,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6290c61..0000000 --- a/branches.md +++ /dev/null @@ -1,57 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cc39401 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d2af5c2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8da7d24..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83R', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '0h87x', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 1ed2f32..a0499bf 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/cli-ctor": "^0.0.3", - "@stdlib/fs-read-file": "^0.0.8", - "@stdlib/process-read-stdin": "^0.0.7", - "@stdlib/streams-node-stdin": "^0.0.7", - "@stdlib/string-base-code-point-at": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-windows": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/constants-unicode-max": "^0.0.7", - "@stdlib/process-exec-path": "^0.0.7", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@stdlib/string-from-code-point": "^0.0.9", - "@stdlib/string-replace": "^0.0.11", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "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", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..63e29d4 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From bca2e8ba62c41506a294e93c9693f96e10dea258 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 05:16:42 +0000 Subject: [PATCH 050/161] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..8da7d24 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,10 +61,10 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83R', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '0h87x', idx ) ); } if ( idx < 0 ) { idx += str.length; @@ -74,7 +74,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 564875c..1ed2f32 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.0.7", "@stdlib/streams-node-stdin": "^0.0.7", "@stdlib/string-base-code-point-at": "^0.0.2", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.8", From 7f674699e0711afc2f4a037cb55122a31d84f1b4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 12:28:50 +0000 Subject: [PATCH 051/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 9a429e0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cc39401..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d2af5c2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 63e29d4..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0e27c12118878e0743a2372f70cb534b9de9647f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 12:29:34 +0000 Subject: [PATCH 052/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 1007 ---- .github/workflows/publish.yml | 242 - .github/workflows/publish_cli.yml | 165 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 107 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 57 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 43 files changed, 6198 insertions(+), 4605 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2169fc2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T03:24:46.458Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4e932aa..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 240c5f2..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1007 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -134,78 +126,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -238,7 +159,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -312,7 +233,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6290c61..0000000 --- a/branches.md +++ /dev/null @@ -1,57 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cc39401 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d2af5c2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8da7d24..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83R', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '0h87x', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 1ed2f32..a0499bf 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/cli-ctor": "^0.0.3", - "@stdlib/fs-read-file": "^0.0.8", - "@stdlib/process-read-stdin": "^0.0.7", - "@stdlib/streams-node-stdin": "^0.0.7", - "@stdlib/string-base-code-point-at": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-windows": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/constants-unicode-max": "^0.0.7", - "@stdlib/process-exec-path": "^0.0.7", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@stdlib/string-from-code-point": "^0.0.9", - "@stdlib/string-replace": "^0.0.11", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "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", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34ef6b6 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 2459882ef190ce711ca8e5beb84b7e961c9ff505 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 05:41:10 +0000 Subject: [PATCH 053/161] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..8da7d24 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,10 +61,10 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0h83R', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '0h87x', idx ) ); } if ( idx < 0 ) { idx += str.length; @@ -74,7 +74,7 @@ function codePointAt( str, idx, backward ) { } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '0h8B3', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 564875c..1ed2f32 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.0.7", "@stdlib/streams-node-stdin": "^0.0.7", "@stdlib/string-base-code-point-at": "^0.0.2", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.8", From 6c41626406d51db5131635ac1d4e28a5f2cb54d5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 13:01:21 +0000 Subject: [PATCH 054/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 9a429e0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cc39401..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d2af5c2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 34ef6b6..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c9b37b03f6962568f77e8da3d81974227c141ffc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 13:02:25 +0000 Subject: [PATCH 055/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 1007 ---- .github/workflows/publish.yml | 242 - .github/workflows/publish_cli.yml | 165 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 107 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 57 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 43 files changed, 6198 insertions(+), 4605 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index baec2fd..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T03:43:37.996Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4e932aa..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 952a131..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1007 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -134,78 +126,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -238,7 +159,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -312,7 +233,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6290c61..0000000 --- a/branches.md +++ /dev/null @@ -1,57 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cc39401 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d2af5c2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8da7d24..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '0h83R', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '0h87x', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '0h8B3', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 1ed2f32..a0499bf 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/cli-ctor": "^0.0.3", - "@stdlib/fs-read-file": "^0.0.8", - "@stdlib/process-read-stdin": "^0.0.7", - "@stdlib/streams-node-stdin": "^0.0.7", - "@stdlib/string-base-code-point-at": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-windows": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/constants-unicode-max": "^0.0.7", - "@stdlib/process-exec-path": "^0.0.7", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@stdlib/string-from-code-point": "^0.0.9", - "@stdlib/string-replace": "^0.0.11", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "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", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..750e603 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 690d3e4da8ff37812d9f00bad97e7beeaf5a25cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 00:36:46 +0000 Subject: [PATCH 056/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..a094a2d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F,Ex', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f,LW', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZM8', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL,M9', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 564875c..1ed2f32 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.0.7", "@stdlib/streams-node-stdin": "^0.0.7", "@stdlib/string-base-code-point-at": "^0.0.2", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.8", From 36c82f729b3965e51d9950a7f80c4972e7d2413a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 00:53:16 +0000 Subject: [PATCH 057/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 9a429e0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cc39401..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,d){var m;if(!s(n))throw new TypeError(i("0h83R",n));if(!t(o))throw new TypeError(i("0h87x",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(i("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",o));if(arguments.length>2){if(!e(d))throw new TypeError(i("0h8B3",d));m=d}else m=!1;return r(n,o,m)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d2af5c2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0h83R', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '0h87x', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '0h8B3', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 750e603..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4099bf0d773e9038805dbf4324b89599e17ca1ef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 00:54:38 +0000 Subject: [PATCH 058/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 992 ---- .github/workflows/publish.yml | 242 - .github/workflows/publish_cli.yml | 165 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 107 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 57 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 45 files changed, 6198 insertions(+), 4604 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4e932aa..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index b61e587..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,992 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -134,78 +126,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -238,7 +159,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -312,7 +233,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6290c61..0000000 --- a/branches.md +++ /dev/null @@ -1,57 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ef80e3a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F,Ex",n));if(!e(o))throw new TypeError(r("1OZ7f,LW",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZM8",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL,M9",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..14536e0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F,Ex', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f,LW', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZM8', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL,M9', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1C,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAK1C,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,WAAYJ,IAE1CC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a094a2d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F,Ex', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f,LW', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZM8', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL,M9', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 1ed2f32..a0499bf 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.0.9", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/cli-ctor": "^0.0.3", - "@stdlib/fs-read-file": "^0.0.8", - "@stdlib/process-read-stdin": "^0.0.7", - "@stdlib/streams-node-stdin": "^0.0.7", - "@stdlib/string-base-code-point-at": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-windows": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/constants-unicode-max": "^0.0.7", - "@stdlib/process-exec-path": "^0.0.7", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@stdlib/string-from-code-point": "^0.0.9", - "@stdlib/string-replace": "^0.0.11", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "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", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d3598d6 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From ce47d4c4e52f86fb1108bdd9b805dd20a10782d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 14:33:36 +0000 Subject: [PATCH 059/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..a094a2d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F,Ex', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f,LW', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZM8', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL,M9', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 8739011..e1938b9 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.1.0", "@stdlib/streams-node-stdin": "^0.1.0", "@stdlib/string-base-code-point-at": "^0.1.0", - "@stdlib/string-format": "^0.1.0" + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.0", From 060127c384db7ddc26ed2fca583811ede6f45c04 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 15:33:11 +0000 Subject: [PATCH 060/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index e20ebe2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ef80e3a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.0.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F,Ex",n));if(!e(o))throw new TypeError(r("1OZ7f,LW",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZM8",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL,M9",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 14536e0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F,Ex', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f,LW', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZM8', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL,M9', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;gfA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1C,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAK1C,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,WAAYJ,IAE1CC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d3598d6..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d56f9d41aac1fa8695ffb662695bf3eddedba59d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 15:35:15 +0000 Subject: [PATCH 061/161] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 992 ---- .github/workflows/publish.yml | 242 - .github/workflows/publish_cli.yml | 165 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 107 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 57 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 46 files changed, 6198 insertions(+), 4639 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 48f5e31..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4e932aa..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index b61e587..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,992 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -145,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -249,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -323,7 +244,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6290c61..0000000 --- a/branches.md +++ /dev/null @@ -1,57 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..185487d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.0-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.0-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.1.0-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F,Ex",n));if(!e(o))throw new TypeError(r("1OZ7f,LW",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZM8",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL,M9",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8316d1f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F,Ex', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f,LW', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZM8', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL,M9', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;8fA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1C,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAK1C,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,WAAYJ,IAE1CC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a094a2d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F,Ex', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f,LW', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZM8', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL,M9', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index e1938b9..4acd75b 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.1.0", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.1.0", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.0", - "@stdlib/cli-ctor": "^0.1.0", - "@stdlib/fs-read-file": "^0.1.0", - "@stdlib/process-read-stdin": "^0.1.0", - "@stdlib/streams-node-stdin": "^0.1.0", - "@stdlib/string-base-code-point-at": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-windows": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/constants-unicode-max": "^0.1.0", - "@stdlib/process-exec-path": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@stdlib/string-from-code-point": "^0.0.9", - "@stdlib/string-replace": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "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", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..f44a006 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From fb3a02c994bdf661926947cab8748905ea71d972 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 16:12:54 +0000 Subject: [PATCH 062/161] Update README.md for ESM bundle v0.1.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1ac7631..36fdede 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import codePointAt from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-code-point-at@esm/index.mjs'; +import codePointAt from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-code-point-at@v0.1.0-esm/index.mjs'; ``` #### codePointAt( string, position\[, backward] ) @@ -112,7 +112,7 @@ This function differs from [`String.prototype.codePointAt`][mdn-string-codepoint - - - - From 03e9c21fca7b7a30cafab54153f95d0e1568298b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Oct 2023 11:00:39 +0000 Subject: [PATCH 066/161] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1009 ---- .github/workflows/publish.yml | 247 - .github/workflows/publish_cli.yml | 170 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 107 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 57 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 181 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 48 files changed, 6198 insertions(+), 4887 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1baa7ec..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T02:31:45.418Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index c418d8b..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 2eecd49..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1009 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -145,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -249,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -323,7 +244,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6290c61..0000000 --- a/branches.md +++ /dev/null @@ -1,57 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..73dedda --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.0-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.0-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.1.0-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F,Ex",n));if(!e(o))throw new TypeError(r("1OZ7f,LW",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZM8",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL,M9",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..109299c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F,Ex', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f,LW', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZM8', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL,M9', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1C,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAK1C,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,WAAYJ,IAE1CC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a094a2d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F,Ex', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f,LW', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZM8', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL,M9', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 0b94c69..4acd75b 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.1.0", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.1.0", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.0", - "@stdlib/cli-ctor": "^0.1.0", - "@stdlib/fs-read-file": "^0.1.0", - "@stdlib/process-read-stdin": "^0.1.0", - "@stdlib/streams-node-stdin": "^0.1.0", - "@stdlib/string-base-code-point-at": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-windows": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/constants-unicode-max": "^0.1.0", - "@stdlib/process-exec-path": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/string-from-code-point": "^0.1.0", - "@stdlib/string-replace": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "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", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2240ad3 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index 0db5440..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 9897f11ea848d5e7853d69604f009e723f6f61ce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 09:47:33 +0000 Subject: [PATCH 067/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..a094a2d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F,Ex', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f,LW', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZM8', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL,M9', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 8b523fd..f81f3ad 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.1.1", "@stdlib/streams-node-stdin": "^0.1.1", "@stdlib/string-base-code-point-at": "^0.1.1", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.1", From ddc2073d4bd35a266c10c31bf0f28c3652e3315e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 13:07:17 +0000 Subject: [PATCH 068/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index e20ebe2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 73dedda..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.0-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.0-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.1.0-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F,Ex",n));if(!e(o))throw new TypeError(r("1OZ7f,LW",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZM8",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL,M9",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 109299c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F,Ex', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f,LW', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZM8', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL,M9', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1C,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAK1C,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,WAAYJ,IAE1CC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2240ad3..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7f0728f8aa58c182fa5ddf7fdefd63ee846d704b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 13:10:49 +0000 Subject: [PATCH 069/161] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1009 ---- .github/workflows/publish.yml | 247 - .github/workflows/publish_cli.yml | 170 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 107 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 57 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 181 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 47 files changed, 6198 insertions(+), 4886 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index c418d8b..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 2eecd49..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1009 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -145,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -249,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -323,7 +244,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6290c61..0000000 --- a/branches.md +++ /dev/null @@ -1,57 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7caf8f8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.1.1-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F,Ex",n));if(!e(o))throw new TypeError(r("1OZ7f,LW",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZM8",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL,M9",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..109299c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F,Ex', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f,LW', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZM8', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL,M9', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1C,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAK1C,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,WAAYJ,IAE1CC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a094a2d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F,Ex', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f,LW', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZM8', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL,M9', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index f81f3ad..4acd75b 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.1.0", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/cli-ctor": "^0.1.1", - "@stdlib/fs-read-file": "^0.1.1", - "@stdlib/process-read-stdin": "^0.1.1", - "@stdlib/streams-node-stdin": "^0.1.1", - "@stdlib/string-base-code-point-at": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-windows": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/constants-unicode-max": "^0.1.1", - "@stdlib/process-exec-path": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/string-from-code-point": "^0.1.0", - "@stdlib/string-replace": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "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", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3268b18 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index 0db5440..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 4b6eb9ae74b6ee0490d711344ed0721fbe26ee0e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 07:19:41 +0000 Subject: [PATCH 070/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..a094a2d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F,Ex', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f,LW', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZM8', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL,M9', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 8b523fd..f81f3ad 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.1.1", "@stdlib/streams-node-stdin": "^0.1.1", "@stdlib/string-base-code-point-at": "^0.1.1", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.1", From 9e96dae683bb42cc70a9a0e42f60d0d7a5dd915c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 11:31:48 +0000 Subject: [PATCH 071/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index e20ebe2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7caf8f8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.1.1-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F,Ex",n));if(!e(o))throw new TypeError(r("1OZ7f,LW",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZM8",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL,M9",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 109299c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F,Ex', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f,LW', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZM8', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL,M9', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1C,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAK1C,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,WAAYJ,IAE1CC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3268b18..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3cd1b43efc81028dc006c903b0510ca25e371708 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 11:34:47 +0000 Subject: [PATCH 072/161] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1009 ---- .github/workflows/publish.yml | 255 - .github/workflows/publish_cli.yml | 170 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 107 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 57 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 48 files changed, 6198 insertions(+), 4747 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index e7e21d0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T02:36:40.657Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index c418d8b..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 2eecd49..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1009 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -145,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -249,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -323,7 +244,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6290c61..0000000 --- a/branches.md +++ /dev/null @@ -1,57 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7caf8f8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.1.1-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F,Ex",n));if(!e(o))throw new TypeError(r("1OZ7f,LW",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZM8",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL,M9",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..109299c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F,Ex', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f,LW', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZM8', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL,M9', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1C,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAK1C,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,WAAYJ,IAE1CC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a094a2d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F,Ex', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f,LW', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZM8', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL,M9', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index f81f3ad..4acd75b 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.1.0", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/cli-ctor": "^0.1.1", - "@stdlib/fs-read-file": "^0.1.1", - "@stdlib/process-read-stdin": "^0.1.1", - "@stdlib/streams-node-stdin": "^0.1.1", - "@stdlib/string-base-code-point-at": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-windows": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/constants-unicode-max": "^0.1.1", - "@stdlib/process-exec-path": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/string-from-code-point": "^0.1.0", - "@stdlib/string-replace": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "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", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..90ba1b8 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 18c8327d75fa2ab606078ff3e04213d15606107d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 06:15:40 +0000 Subject: [PATCH 073/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..a094a2d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F,Ex', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f,LW', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZM8', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL,M9', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index a8caee7..65b9dcd 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.1.1", "@stdlib/streams-node-stdin": "^0.1.1", "@stdlib/string-base-code-point-at": "^0.1.1", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.1", From 2e9e149552ca46bd8641e9527c98740e0cd6fd9c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 00:42:33 +0000 Subject: [PATCH 074/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index e20ebe2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7caf8f8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.1.1-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F,Ex",n));if(!e(o))throw new TypeError(r("1OZ7f,LW",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZM8",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL,M9",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 109299c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F,Ex', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f,LW', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZM8', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL,M9', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1C,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAK1C,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,WAAYJ,IAE1CC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 90ba1b8..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 77f1bee948f7fbb345879d6e37dbd8c43394cb35 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 00:45:08 +0000 Subject: [PATCH 075/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1011 ---- .github/workflows/publish.yml | 255 - .github/workflows/publish_cli.yml | 170 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 107 +- benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 57 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 48 files changed, 6198 insertions(+), 4744 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index af28f53..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T02:46:23.680Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index c418d8b..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 6957ebf..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1011 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -145,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -249,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -323,7 +244,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 807ffe6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6290c61..0000000 --- a/branches.md +++ /dev/null @@ -1,57 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7caf8f8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.1.1-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F,Ex",n));if(!e(o))throw new TypeError(r("1OZ7f,LW",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZM8",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL,M9",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..109299c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F,Ex', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f,LW', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZM8', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL,M9', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1C,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAK1C,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,WAAYJ,IAE1CC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a094a2d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F,Ex', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f,LW', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZM8', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL,M9', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 65b9dcd..4acd75b 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.1.0", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/cli-ctor": "^0.1.1", - "@stdlib/fs-read-file": "^0.1.1", - "@stdlib/process-read-stdin": "^0.1.1", - "@stdlib/streams-node-stdin": "^0.1.1", - "@stdlib/string-base-code-point-at": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-windows": "^0.1.1", - "@stdlib/bench": "^0.2.1", - "@stdlib/constants-unicode-max": "^0.1.1", - "@stdlib/process-exec-path": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/string-from-code-point": "^0.1.0", - "@stdlib/string-replace": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "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", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1dc3dba --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 529c85dbaebfdd773e64352c0f80e170db6badde Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 03:57:17 +0000 Subject: [PATCH 076/161] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e72449d..4c43ca1 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.1.1", "@stdlib/streams-node-stdin": "^0.1.1", "@stdlib/string-base-code-point-at": "^0.1.1", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.1", From 72e3217bfd142ec8fc214848c126d62ded4feb30 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 10:00:13 +0000 Subject: [PATCH 077/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7caf8f8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.1.1-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F,Ex",n));if(!e(o))throw new TypeError(r("1OZ7f,LW",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZM8",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL,M9",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 109299c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F,Ex', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f,LW', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZM8', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL,M9', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1C,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAK1C,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,WAAYJ,IAE1CC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1dc3dba..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3677bf6903603cfe8bcdb74487f3504e552d0831 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 10:00:34 +0000 Subject: [PATCH 078/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1011 ---- .github/workflows/publish.yml | 255 - .github/workflows/publish_cli.yml | 170 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 107 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 57 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 49 files changed, 6198 insertions(+), 4750 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0973399..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T02:24:12.799Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1df8818..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 96d504a..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1011 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -145,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -249,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -323,7 +244,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6290c61..0000000 --- a/branches.md +++ /dev/null @@ -1,57 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..674b979 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.1.1-esm/index.mjs";function n(n,a,m){var d;if(!t(n))throw new TypeError(s("invalid argument. First argument must be a string. Value: `%s`.",n));if(!i(a))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",a));if(a<0&&(a+=n.length),a<0||a>=n.length)throw new RangeError(s("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",a));if(arguments.length>2){if(!e(m))throw new TypeError(s("invalid argument. Third argument must be a boolean. Value: `%s`.",m));d=m}else d=!1;return r(n,a,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..c454386 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/string-format';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;4fA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,kEAAmEN,IAEjG,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,qEAAsEL,IAKpG,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,mEAAoEJ,IAElGC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6493992..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 4c43ca1..4acd75b 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.1.0", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/cli-ctor": "^0.1.1", - "@stdlib/fs-read-file": "^0.1.1", - "@stdlib/process-read-stdin": "^0.1.1", - "@stdlib/streams-node-stdin": "^0.1.1", - "@stdlib/string-base-code-point-at": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-windows": "^0.1.1", - "@stdlib/constants-unicode-max": "^0.1.1", - "@stdlib/process-exec-path": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/string-from-code-point": "^0.1.0", - "@stdlib/string-replace": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..230fd2c --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From e9d99ac1d050332839a37b47623fbcf8160a4252 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 04:14:30 +0000 Subject: [PATCH 079/161] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e72449d..4c43ca1 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.1.1", "@stdlib/streams-node-stdin": "^0.1.1", "@stdlib/string-base-code-point-at": "^0.1.1", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.1", From 20d12e274a41a4df72574ea4e7d64ac3ab7e9178 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 08:56:44 +0000 Subject: [PATCH 080/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 674b979..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.1.1-esm/index.mjs";function n(n,a,m){var d;if(!t(n))throw new TypeError(s("invalid argument. First argument must be a string. Value: `%s`.",n));if(!i(a))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",a));if(a<0&&(a+=n.length),a<0||a>=n.length)throw new RangeError(s("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",a));if(arguments.length>2){if(!e(m))throw new TypeError(s("invalid argument. Third argument must be a boolean. Value: `%s`.",m));d=m}else d=!1;return r(n,a,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index c454386..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/string-format';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;4fA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,kEAAmEN,IAEjG,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,qEAAsEL,IAKpG,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,mEAAoEJ,IAElGC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 230fd2c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1afc87db52a2c86c1ecc8c09c9e10eea3a0ed426 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 08:57:10 +0000 Subject: [PATCH 081/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1012 ---- .github/workflows/publish.yml | 255 - .github/workflows/publish_cli.yml | 170 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 49 files changed, 6198 insertions(+), 4756 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 90beb5e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T02:52:38.471Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 1df8818..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 303a99a..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1012 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..674b979 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.1.1-esm/index.mjs";function n(n,a,m){var d;if(!t(n))throw new TypeError(s("invalid argument. First argument must be a string. Value: `%s`.",n));if(!i(a))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",a));if(a<0&&(a+=n.length),a<0||a>=n.length)throw new RangeError(s("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",a));if(arguments.length>2){if(!e(m))throw new TypeError(s("invalid argument. Third argument must be a boolean. Value: `%s`.",m));d=m}else d=!1;return r(n,a,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..c454386 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/string-format';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;4fA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,kEAAmEN,IAEjG,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,qEAAsEL,IAKpG,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,mEAAoEJ,IAElGC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6493992..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 4c43ca1..4acd75b 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.1.0", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/cli-ctor": "^0.1.1", - "@stdlib/fs-read-file": "^0.1.1", - "@stdlib/process-read-stdin": "^0.1.1", - "@stdlib/streams-node-stdin": "^0.1.1", - "@stdlib/string-base-code-point-at": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-windows": "^0.1.1", - "@stdlib/constants-unicode-max": "^0.1.1", - "@stdlib/process-exec-path": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/string-from-code-point": "^0.1.0", - "@stdlib/string-replace": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..68385bf --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 6fbdde65e574b1fc601d6356a04d21cf59408db9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 07:58:41 +0000 Subject: [PATCH 082/161] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 089ade0..87fcad9 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.0", "@stdlib/streams-node-stdin": "^0.2.0", "@stdlib/string-base-code-point-at": "^0.2.0", - "@stdlib/string-format": "^0.2.0" + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.1", From aa290bf31c79e3de869a9c24507a19e876fd0587 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 16:03:23 +0000 Subject: [PATCH 083/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 674b979..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.1.1-esm/index.mjs";function n(n,a,m){var d;if(!t(n))throw new TypeError(s("invalid argument. First argument must be a string. Value: `%s`.",n));if(!i(a))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",a));if(a<0&&(a+=n.length),a<0||a>=n.length)throw new RangeError(s("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",a));if(arguments.length>2){if(!e(m))throw new TypeError(s("invalid argument. Third argument must be a boolean. Value: `%s`.",m));d=m}else d=!1;return r(n,a,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index c454386..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/string-format';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;4fA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,kEAAmEN,IAEjG,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,qEAAsEL,IAKpG,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,mEAAoEJ,IAElGC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 68385bf..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6b2523cf041375abaada9e5c42323727a612ebc4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 16:04:18 +0000 Subject: [PATCH 084/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1012 ---- .github/workflows/publish.yml | 255 - .github/workflows/publish_cli.yml | 170 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 48 files changed, 6198 insertions(+), 4759 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 7eba82a..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e898b7d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1012 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6626af6 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.0-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.0-esm/index.mjs";import{isPrimitive as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.0-esm/index.mjs";function n(n,a,m){var d;if(!t(n))throw new TypeError(s("invalid argument. First argument must be a string. Value: `%s`.",n));if(!i(a))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",a));if(a<0&&(a+=n.length),a<0||a>=n.length)throw new RangeError(s("invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.",a));if(arguments.length>2){if(!e(m))throw new TypeError(s("invalid argument. Third argument must be a boolean. Value: `%s`.",m));d=m}else d=!1;return r(n,a,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..c454386 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/string-format';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;4fA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,kEAAmEN,IAEjG,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,qEAAsEL,IAKpG,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,2GAA4GL,IAE3I,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,mEAAoEJ,IAElGC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6493992..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 87fcad9..1c0a67e 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.0", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.0", - "@stdlib/assert-is-integer": "^0.2.0", - "@stdlib/assert-is-string": "^0.2.0", - "@stdlib/cli-ctor": "^0.1.1", - "@stdlib/fs-read-file": "^0.2.0", - "@stdlib/process-read-stdin": "^0.2.0", - "@stdlib/streams-node-stdin": "^0.2.0", - "@stdlib/string-base-code-point-at": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-windows": "^0.1.1", - "@stdlib/constants-unicode-max": "^0.1.1", - "@stdlib/process-exec-path": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/string-from-code-point": "^0.1.0", - "@stdlib/string-replace": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1516484 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From ba87e53ee617f2bb102469c73f5fa54c8c46d6fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 19:18:35 +0000 Subject: [PATCH 085/161] Update README.md for ESM bundle v0.2.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7430f9f..fe7dc49 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import codePointAt from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-code-point-at@esm/index.mjs'; +import codePointAt from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-code-point-at@v0.2.0-esm/index.mjs'; ``` #### codePointAt( string, position\[, backward] ) @@ -112,7 +112,7 @@ This function differs from [`String.prototype.codePointAt`][mdn-string-codepoint - - - - From f85cad1caeb3ed57a9e27d8ed624a3f6b7debf0b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 15:36:09 +0000 Subject: [PATCH 089/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1012 ----- .github/workflows/publish.yml | 249 -- .github/workflows/publish_cli.yml | 176 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 71 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 181 - 48 files changed, 4863 insertions(+), 4759 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e898b7d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1012 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d027e04 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.1-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index bb69f2d..61c0219 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.1", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/cli-ctor": "^0.2.1", - "@stdlib/fs-read-file": "^0.2.1", - "@stdlib/process-read-stdin": "^0.2.1", - "@stdlib/streams-node-stdin": "^0.2.1", - "@stdlib/string-base-code-point-at": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.0", - "@stdlib/assert-is-windows": "^0.2.1", - "@stdlib/constants-unicode-max": "^0.2.1", - "@stdlib/process-exec-path": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.0", - "@stdlib/string-from-code-point": "^0.2.0", - "@stdlib/string-replace": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..f9d4baa --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 2fd668f2406adaf7a3901e6a2f560ff2e5f6dcae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 15:56:34 +0000 Subject: [PATCH 090/161] Update README.md for ESM bundle v0.2.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 299defc..1092991 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import codePointAt from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-code-point-at@esm/index.mjs'; +import codePointAt from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-code-point-at@v0.2.1-esm/index.mjs'; ``` #### codePointAt( string, position\[, backward] ) @@ -112,7 +112,7 @@ This function differs from [`String.prototype.codePointAt`][mdn-string-codepoint - - - - From f2657cac124805d853bb9641676214ca9f1bb533 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 07:35:01 +0000 Subject: [PATCH 094/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1012 ----- .github/workflows/publish.yml | 249 -- .github/workflows/publish_cli.yml | 176 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 181 - 49 files changed, 4863 insertions(+), 4762 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 7f1ae0b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T02:47:08.521Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e898b7d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1012 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1476c38 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.1-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 554c910..61c0219 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.1", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/cli-ctor": "^0.2.1", - "@stdlib/fs-read-file": "^0.2.1", - "@stdlib/process-read-stdin": "^0.2.1", - "@stdlib/streams-node-stdin": "^0.2.1", - "@stdlib/string-base-code-point-at": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-windows": "^0.2.1", - "@stdlib/constants-unicode-max": "^0.2.1", - "@stdlib/process-exec-path": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.1", - "@stdlib/string-replace": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dab1234 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 6d7a986c7250ade1ffe93007cea5ef285fd40528 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 03:27:51 +0000 Subject: [PATCH 095/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 3ca6083..554c910 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.1", "@stdlib/streams-node-stdin": "^0.2.1", "@stdlib/string-base-code-point-at": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { From e6ec7cc4ac73790d9f25cf32ab82db13d9478d3b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:26:59 +0000 Subject: [PATCH 096/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1476c38..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.1-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dab1234..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9511090e8ca851a19ea439e338fd20d88f979417 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:27:09 +0000 Subject: [PATCH 097/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1012 ----- .github/workflows/publish.yml | 249 -- .github/workflows/publish_cli.yml | 176 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 181 - 49 files changed, 4863 insertions(+), 4765 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0cf80c7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T02:19:44.685Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index df867aa..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1012 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1476c38 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.1-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 554c910..61c0219 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.1", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/cli-ctor": "^0.2.1", - "@stdlib/fs-read-file": "^0.2.1", - "@stdlib/process-read-stdin": "^0.2.1", - "@stdlib/streams-node-stdin": "^0.2.1", - "@stdlib/string-base-code-point-at": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-windows": "^0.2.1", - "@stdlib/constants-unicode-max": "^0.2.1", - "@stdlib/process-exec-path": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.1", - "@stdlib/string-replace": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dab1234 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 85d0c303582392d41adef3638a109c46beb9bbc8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 23:36:56 +0000 Subject: [PATCH 098/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 3ca6083..554c910 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.1", "@stdlib/streams-node-stdin": "^0.2.1", "@stdlib/string-base-code-point-at": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { From f1ea7b5e10dab9744a7e1064bb2ab31789d2ab99 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 04:19:32 +0000 Subject: [PATCH 099/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1476c38..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.1-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dab1234..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b3b4e353a3a099480af6df151aaa843574f4edc6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 04:19:55 +0000 Subject: [PATCH 100/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1012 ----- .github/workflows/publish.yml | 249 -- .github/workflows/publish_cli.yml | 176 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 134 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 181 - 48 files changed, 4863 insertions(+), 4766 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index df867aa..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1012 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1476c38 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.1-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 554c910..61c0219 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.1", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/cli-ctor": "^0.2.1", - "@stdlib/fs-read-file": "^0.2.1", - "@stdlib/process-read-stdin": "^0.2.1", - "@stdlib/streams-node-stdin": "^0.2.1", - "@stdlib/string-base-code-point-at": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-windows": "^0.2.1", - "@stdlib/constants-unicode-max": "^0.2.1", - "@stdlib/process-exec-path": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.1", - "@stdlib/string-replace": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dab1234 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 6e9bf72c6bdd76dd568f402a485dd33d702d4ae5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 18:12:32 +0000 Subject: [PATCH 101/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 67c7a33..a95cb2b 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.2", "@stdlib/streams-node-stdin": "^0.2.2", "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From 5f67a67b9d0c0813ea20140faaf1234309df7b11 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 18:15:45 +0000 Subject: [PATCH 102/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1476c38..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.1-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dab1234..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fa0e7bcf7ee7cbf897000584ac3e442cc492d1d9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 18:15:58 +0000 Subject: [PATCH 103/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1008 ----- .github/workflows/publish.yml | 252 -- .github/workflows/publish_cli.yml | 175 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 181 - 48 files changed, 4863 insertions(+), 4972 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 663474a..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1008 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ac9adb1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index a95cb2b..7df3e9c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.2", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/cli-ctor": "^0.2.2", - "@stdlib/fs-read-file": "^0.2.2", - "@stdlib/process-read-stdin": "^0.2.2", - "@stdlib/streams-node-stdin": "^0.2.2", - "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-windows": "^0.2.2", - "@stdlib/constants-unicode-max": "^0.2.2", - "@stdlib/process-exec-path": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.1", - "@stdlib/string-replace": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5dc7f3d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 7f7578bdf387ad53a25704d580deeb37babb88eb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 18:17:05 +0000 Subject: [PATCH 104/161] Update README.md for ESM bundle v0.2.2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 118400f..097ecee 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import codePointAt from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-code-point-at@esm/index.mjs'; +import codePointAt from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-code-point-at@v0.2.2-esm/index.mjs'; ``` #### codePointAt( string, position\[, backward] ) @@ -112,7 +112,7 @@ This function differs from [`String.prototype.codePointAt`][mdn-string-codepoint - - - - From 856c9a169fcee3e072f8b70a165741c55fe7611c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 07:38:13 +0000 Subject: [PATCH 108/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1008 ----- .github/workflows/publish.yml | 252 -- .github/workflows/publish_cli.yml | 175 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 168 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 181 - 49 files changed, 4863 insertions(+), 4941 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a36c47c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T02:50:51.347Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 663474a..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1008 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fdf8b51 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 6a50c18..7df3e9c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.2", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/cli-ctor": "^0.2.2", - "@stdlib/fs-read-file": "^0.2.2", - "@stdlib/process-read-stdin": "^0.2.2", - "@stdlib/streams-node-stdin": "^0.2.2", - "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-windows": "^0.2.2", - "@stdlib/constants-unicode-max": "^0.2.2", - "@stdlib/process-exec-path": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..667d6ae --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 800077a16bb03909d8a6eb29a68297630119acf8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 18:46:53 +0000 Subject: [PATCH 109/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 26c29c0..6a50c18 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.2", "@stdlib/streams-node-stdin": "^0.2.2", "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From 5c79b7172f50c98c4af50920e65a69ef517ecbbf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 21:30:32 +0000 Subject: [PATCH 110/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fdf8b51..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 667d6ae..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1ba7870d2064d8b560ea238d1f9ab23c5375bf3f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 21:30:46 +0000 Subject: [PATCH 111/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1008 ----- .github/workflows/publish.yml | 252 -- .github/workflows/publish_cli.yml | 175 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 181 - 49 files changed, 4863 insertions(+), 4975 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 3b69f78..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T17:54:12.871Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 663474a..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1008 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fdf8b51 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 6a50c18..7df3e9c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.2", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/cli-ctor": "^0.2.2", - "@stdlib/fs-read-file": "^0.2.2", - "@stdlib/process-read-stdin": "^0.2.2", - "@stdlib/streams-node-stdin": "^0.2.2", - "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-windows": "^0.2.2", - "@stdlib/constants-unicode-max": "^0.2.2", - "@stdlib/process-exec-path": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..667d6ae --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 004f3b444af24bb20edd3bea1b4d73f55cf4cbcd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 04:08:19 +0000 Subject: [PATCH 112/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 26c29c0..6a50c18 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.2", "@stdlib/streams-node-stdin": "^0.2.2", "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From b0eb06c40e445ce778a79108a37d44da66afc6f2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 07:37:42 +0000 Subject: [PATCH 113/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fdf8b51..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 667d6ae..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3c821ff11e9c030aeb0bb976d5e6a4e507d5d1c7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 07:37:56 +0000 Subject: [PATCH 114/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1008 ----- .github/workflows/publish.yml | 252 -- .github/workflows/publish_cli.yml | 175 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 181 - 49 files changed, 4863 insertions(+), 4975 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c8b5baa..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T03:01:28.327Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 663474a..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1008 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fdf8b51 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 6a50c18..7df3e9c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.2", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/cli-ctor": "^0.2.2", - "@stdlib/fs-read-file": "^0.2.2", - "@stdlib/process-read-stdin": "^0.2.2", - "@stdlib/streams-node-stdin": "^0.2.2", - "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-windows": "^0.2.2", - "@stdlib/constants-unicode-max": "^0.2.2", - "@stdlib/process-exec-path": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..667d6ae --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 96cd04fd9f2f38c795bf01967898233a6e4f1c6f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 04:12:06 +0000 Subject: [PATCH 115/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 26c29c0..6a50c18 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.2", "@stdlib/streams-node-stdin": "^0.2.2", "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From c692fc4802467338d7254fc52bf94e877c89f042 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 07:36:05 +0000 Subject: [PATCH 116/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fdf8b51..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 667d6ae..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fd48dc5212afdce909e0050113d5667e09d70340 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 07:36:17 +0000 Subject: [PATCH 117/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1008 ----- .github/workflows/publish.yml | 252 -- .github/workflows/publish_cli.yml | 175 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 181 - 49 files changed, 4863 insertions(+), 4975 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 93aace6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T03:11:02.811Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 663474a..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1008 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fdf8b51 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 6a50c18..7df3e9c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.2", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/cli-ctor": "^0.2.2", - "@stdlib/fs-read-file": "^0.2.2", - "@stdlib/process-read-stdin": "^0.2.2", - "@stdlib/streams-node-stdin": "^0.2.2", - "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-windows": "^0.2.2", - "@stdlib/constants-unicode-max": "^0.2.2", - "@stdlib/process-exec-path": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..667d6ae --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From bb24709d045b66b60b6af7edbffac077a107b914 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 04:10:32 +0000 Subject: [PATCH 118/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 26c29c0..6a50c18 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.2", "@stdlib/streams-node-stdin": "^0.2.2", "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From 48f2215b0450d43d37ac58a0ba7e8b02df7d1cdd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 07:09:18 +0000 Subject: [PATCH 119/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fdf8b51..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 667d6ae..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a22766daa34492ab19d0ebe2ede770c91277d633 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 07:09:30 +0000 Subject: [PATCH 120/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1008 ----- .github/workflows/publish.yml | 252 -- .github/workflows/publish_cli.yml | 175 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 -- test/test.js | 181 - 49 files changed, 4863 insertions(+), 4975 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a88e306..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T03:12:19.218Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 663474a..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1008 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fdf8b51 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 6a50c18..7df3e9c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.2", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/cli-ctor": "^0.2.2", - "@stdlib/fs-read-file": "^0.2.2", - "@stdlib/process-read-stdin": "^0.2.2", - "@stdlib/streams-node-stdin": "^0.2.2", - "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-windows": "^0.2.2", - "@stdlib/constants-unicode-max": "^0.2.2", - "@stdlib/process-exec-path": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..667d6ae --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From b93692c33f6315b01296a6b460bdc1c8d07e3349 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 04:23:40 +0000 Subject: [PATCH 121/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 26c29c0..6a50c18 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.2", "@stdlib/streams-node-stdin": "^0.2.2", "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From 092691f173dec4e1eed4cbfee3d0b2f062d59ab0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 07:44:17 +0000 Subject: [PATCH 122/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fdf8b51..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 667d6ae..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ea90dae24426ec31a85ca0a7789c414fbe8bbce7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 07:44:31 +0000 Subject: [PATCH 123/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1008 ---- .github/workflows/publish.yml | 252 - .github/workflows/publish_cli.yml | 175 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 50 files changed, 4863 insertions(+), 5080 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index bb2fdb9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T03:17:51.156Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 663474a..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1008 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fdf8b51 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 6a50c18..7df3e9c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.2", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/cli-ctor": "^0.2.2", - "@stdlib/fs-read-file": "^0.2.2", - "@stdlib/process-read-stdin": "^0.2.2", - "@stdlib/streams-node-stdin": "^0.2.2", - "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-windows": "^0.2.2", - "@stdlib/constants-unicode-max": "^0.2.2", - "@stdlib/process-exec-path": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..667d6ae --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 57da11713e39046e457c3a1cd0273653dae47e09 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 6 Jan 2025 01:44:02 +0000 Subject: [PATCH 124/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 26c29c0..6a50c18 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.2", "@stdlib/streams-node-stdin": "^0.2.2", "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From 94433fbd52019a87f9baa13fa9dd53397079a710 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 6 Jan 2025 01:47:28 +0000 Subject: [PATCH 125/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fdf8b51..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 667d6ae..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 67ae847d91288a18b7d5ac6e6a68c913eb27f4ea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 6 Jan 2025 01:47:47 +0000 Subject: [PATCH 126/161] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1008 ---- .github/workflows/publish.yml | 252 - .github/workflows/publish_cli.yml | 175 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 50 files changed, 4863 insertions(+), 5080 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2b1ff50..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-01-06T01:43:21.119Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2074405..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 663474a..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1008 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..77780c1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 6a50c18..7df3e9c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.2", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/cli-ctor": "^0.2.2", - "@stdlib/fs-read-file": "^0.2.2", - "@stdlib/process-read-stdin": "^0.2.2", - "@stdlib/streams-node-stdin": "^0.2.2", - "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-windows": "^0.2.2", - "@stdlib/constants-unicode-max": "^0.2.2", - "@stdlib/process-exec-path": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..667d6ae --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 04dfc8320f38ccd01f1a8b77a29050db2427a101 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 02:10:05 +0000 Subject: [PATCH 127/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 26c29c0..6a50c18 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.2", "@stdlib/streams-node-stdin": "^0.2.2", "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From 47bfdf8800063a044be933302ff049cc75608598 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 03:08:25 +0000 Subject: [PATCH 128/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 77780c1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 667d6ae..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d7042f5a9690bc63084471428bf09e6ad5105541 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 03:08:39 +0000 Subject: [PATCH 129/161] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1008 ---- .github/workflows/publish.yml | 252 - .github/workflows/publish_cli.yml | 175 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 50 files changed, 4863 insertions(+), 5083 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 05d9a56..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-24T01:50:50.459Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8a3fbd5..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 663474a..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1008 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..77780c1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 6a50c18..7df3e9c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.2", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/cli-ctor": "^0.2.2", - "@stdlib/fs-read-file": "^0.2.2", - "@stdlib/process-read-stdin": "^0.2.2", - "@stdlib/streams-node-stdin": "^0.2.2", - "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-windows": "^0.2.2", - "@stdlib/constants-unicode-max": "^0.2.2", - "@stdlib/process-exec-path": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..667d6ae --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 7c22846d5a5a45e38f379741ca988bd0712e62e9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Mar 2025 00:30:55 +0000 Subject: [PATCH 130/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 26c29c0..6a50c18 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.2", "@stdlib/streams-node-stdin": "^0.2.2", "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From e148bf391ea5c3931811f975bf2d2d62814c724c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Mar 2025 00:32:32 +0000 Subject: [PATCH 131/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 77780c1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 667d6ae..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 683a316ad7b746baf67f5bb062ca92572c336f8c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Mar 2025 00:32:48 +0000 Subject: [PATCH 132/161] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1008 ---- .github/workflows/publish.yml | 252 - .github/workflows/publish_cli.yml | 175 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 50 files changed, 4863 insertions(+), 5083 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 9ccc52a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-03T00:30:17.269Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8a3fbd5..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 663474a..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1008 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..77780c1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 6a50c18..7df3e9c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.2", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/cli-ctor": "^0.2.2", - "@stdlib/fs-read-file": "^0.2.2", - "@stdlib/process-read-stdin": "^0.2.2", - "@stdlib/streams-node-stdin": "^0.2.2", - "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-windows": "^0.2.2", - "@stdlib/constants-unicode-max": "^0.2.2", - "@stdlib/process-exec-path": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..667d6ae --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 4602b0a57957883390845ddffae6b45bfdfea490 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 00:58:39 +0000 Subject: [PATCH 133/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 26c29c0..6a50c18 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.2", "@stdlib/streams-node-stdin": "^0.2.2", "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From d96596c0f1583019735ea8bb5722b25f679fd4b1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 01:20:12 +0000 Subject: [PATCH 134/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 77780c1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 667d6ae..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c6f3e10f3a8305f9129bc579467bcd8ce1258113 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 01:20:29 +0000 Subject: [PATCH 135/161] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1008 ---- .github/workflows/publish.yml | 252 - .github/workflows/publish_cli.yml | 175 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 50 files changed, 4863 insertions(+), 5083 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index f328c95..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-10T00:52:23.385Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8a3fbd5..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 663474a..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1008 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..77780c1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 6a50c18..7df3e9c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.2", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/cli-ctor": "^0.2.2", - "@stdlib/fs-read-file": "^0.2.2", - "@stdlib/process-read-stdin": "^0.2.2", - "@stdlib/streams-node-stdin": "^0.2.2", - "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-windows": "^0.2.2", - "@stdlib/constants-unicode-max": "^0.2.2", - "@stdlib/process-exec-path": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..667d6ae --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 4098d49747cfd79c2258f086decd4f2bb047071a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 30 Jan 2026 06:28:52 +0000 Subject: [PATCH 136/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 26c29c0..6a50c18 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.2", "@stdlib/streams-node-stdin": "^0.2.2", "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From 14eaea70143123cfbd80a0b498320fae93dba65b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 30 Jan 2026 07:13:53 +0000 Subject: [PATCH 137/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 77780c1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 667d6ae..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e41dc263a0543eeeae4aac476a355407035b6c18 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 30 Jan 2026 07:14:16 +0000 Subject: [PATCH 138/161] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1044 ---- .github/workflows/publish.yml | 261 - .github/workflows/publish_cli.yml | 184 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 49 files changed, 4863 insertions(+), 5205 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8a3fbd5..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index a74ef1e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1044 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 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 + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..de79b8a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index 6a50c18..7df3e9c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.2", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/cli-ctor": "^0.2.2", - "@stdlib/fs-read-file": "^0.2.2", - "@stdlib/process-read-stdin": "^0.2.2", - "@stdlib/streams-node-stdin": "^0.2.2", - "@stdlib/string-base-code-point-at": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-windows": "^0.2.2", - "@stdlib/constants-unicode-max": "^0.2.2", - "@stdlib/process-exec-path": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..667d6ae --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From c84ca721fa4b71b70ad1eddf70c2948de99b2321 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Feb 2026 23:39:07 +0000 Subject: [PATCH 139/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index f0a4acf..b74c70d 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.2", "@stdlib/streams-node-stdin": "^0.2.3", "@stdlib/string-base-code-point-at": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { From 60a126649c1c78b1909fd0aa1f86aa3c82bfee56 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Feb 2026 23:43:05 +0000 Subject: [PATCH 140/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index de79b8a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.2-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 667d6ae..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cfc15d922b95247aa29019bc8d41a51ab57a4611 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Feb 2026 23:43:21 +0000 Subject: [PATCH 141/161] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1044 ---- .github/workflows/publish.yml | 261 - .github/workflows/publish_cli.yml | 184 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 212 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 49 files changed, 4863 insertions(+), 5208 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8a3fbd5..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index a74ef1e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1044 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 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 + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0d553f2 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.3-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index b74c70d..62f319c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.3", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/cli-ctor": "^0.2.3", - "@stdlib/fs-read-file": "^0.2.3", - "@stdlib/process-read-stdin": "^0.2.2", - "@stdlib/streams-node-stdin": "^0.2.3", - "@stdlib/string-base-code-point-at": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-windows": "^0.2.3", - "@stdlib/constants-unicode-max": "^0.2.3", - "@stdlib/process-exec-path": "^0.2.3", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/string-from-code-point": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..78bacc9 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 54f4e436501c6dcb27eb0d683f93d17c5f72493c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Feb 2026 23:50:05 +0000 Subject: [PATCH 142/161] Update README.md for ESM bundle v0.2.3 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f620358..2207728 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import codePointAt from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-code-point-at@esm/index.mjs'; +import codePointAt from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-code-point-at@v0.2.3-esm/index.mjs'; ``` #### codePointAt( string, position\[, backward] ) @@ -112,7 +112,7 @@ This function differs from [`String.prototype.codePointAt`][mdn-string-codepoint - - - - From 11df763981690175dd6c076bbae89f43a84dd60f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 04:29:20 +0000 Subject: [PATCH 146/161] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1044 ---- .github/workflows/publish.yml | 261 - .github/workflows/publish_cli.yml | 184 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 212 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 88 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 50 files changed, 4863 insertions(+), 5209 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b141d1b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-09T02:28:54.059Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8a3fbd5..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index a74ef1e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1044 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 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 + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5607702..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0d553f2 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.3-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index bbc1dc0..62f319c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.3", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/cli-ctor": "^0.2.3", - "@stdlib/fs-read-file": "^0.2.3", - "@stdlib/process-read-stdin": "^0.2.3", - "@stdlib/streams-node-stdin": "^0.2.3", - "@stdlib/string-base-code-point-at": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-windows": "^0.2.3", - "@stdlib/constants-unicode-max": "^0.2.3", - "@stdlib/process-exec-path": "^0.2.3", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/string-from-code-point": "^0.2.3", - "@stdlib/string-replace": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..78bacc9 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From ca839d10068c893da68aaefc0e196fab14e755ff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 19 Apr 2026 07:35:13 +0000 Subject: [PATCH 147/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 8be14ac..bbc1dc0 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.3", "@stdlib/streams-node-stdin": "^0.2.3", "@stdlib/string-base-code-point-at": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { From 1bdab3adc3222a51f5f485ddc31d6dec55611413 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 19 Apr 2026 07:56:23 +0000 Subject: [PATCH 148/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0d553f2..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.3-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 78bacc9..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f60201196204679727386f27ca013efb68d6efb6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 19 Apr 2026 07:56:42 +0000 Subject: [PATCH 149/161] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1044 ---- .github/workflows/publish.yml | 261 - .github/workflows/publish_cli.yml | 184 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 247 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 49 files changed, 4863 insertions(+), 5255 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8a3fbd5..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index a74ef1e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1044 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 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 + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8b3beca..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::built-in', pkg ), opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0d553f2 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.3-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index bbc1dc0..62f319c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.3", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/cli-ctor": "^0.2.3", - "@stdlib/fs-read-file": "^0.2.3", - "@stdlib/process-read-stdin": "^0.2.3", - "@stdlib/streams-node-stdin": "^0.2.3", - "@stdlib/string-base-code-point-at": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-windows": "^0.2.3", - "@stdlib/constants-unicode-max": "^0.2.3", - "@stdlib/process-exec-path": "^0.2.3", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/string-from-code-point": "^0.2.3", - "@stdlib/string-replace": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..78bacc9 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 4280606bcaa980d01cd551c5b8b5b2328d3a60d7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 27 Apr 2026 03:25:08 +0000 Subject: [PATCH 150/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 8be14ac..bbc1dc0 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.3", "@stdlib/streams-node-stdin": "^0.2.3", "@stdlib/string-base-code-point-at": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { From e4154ee30a771f5638a77e41015c745eaf8457fa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 27 Apr 2026 03:29:17 +0000 Subject: [PATCH 151/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0d553f2..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.3-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 78bacc9..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7c86d5ca09ebb2624b1013f148f6e23acd0b15ab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 27 Apr 2026 03:29:36 +0000 Subject: [PATCH 152/161] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1044 ---- .github/workflows/publish.yml | 261 - .github/workflows/publish_cli.yml | 184 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 247 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 50 files changed, 4863 insertions(+), 5261 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 658e23e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-04-27T03:23:41.477Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8a3fbd5..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index a74ef1e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1044 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 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 + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8b3beca..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::built-in', pkg ), opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0d553f2 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.3-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index bbc1dc0..62f319c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.3", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/cli-ctor": "^0.2.3", - "@stdlib/fs-read-file": "^0.2.3", - "@stdlib/process-read-stdin": "^0.2.3", - "@stdlib/streams-node-stdin": "^0.2.3", - "@stdlib/string-base-code-point-at": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-windows": "^0.2.3", - "@stdlib/constants-unicode-max": "^0.2.3", - "@stdlib/process-exec-path": "^0.2.3", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/string-from-code-point": "^0.2.3", - "@stdlib/string-replace": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..78bacc9 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From 3338261348ad71da4af5707de8d7bd92fb61239c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 5 Jun 2026 03:36:27 +0000 Subject: [PATCH 153/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 8be14ac..bbc1dc0 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.3", "@stdlib/streams-node-stdin": "^0.2.3", "@stdlib/string-base-code-point-at": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { From 6cad388bf93935c2b9adbbea53f40d7e7f0d1fb1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 5 Jun 2026 04:03:51 +0000 Subject: [PATCH 154/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0d553f2..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.3-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 78bacc9..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 909077941b909476d7494ab4cbd871d60a3cd9df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 5 Jun 2026 04:04:10 +0000 Subject: [PATCH 155/161] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1044 ---- .github/workflows/publish.yml | 261 - .github/workflows/publish_cli.yml | 184 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 247 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 50 files changed, 4863 insertions(+), 5274 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0d0bbca..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-06-05T03:28:44.184Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8a3fbd5..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index a74ef1e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1044 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 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 + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8b3beca..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::built-in', pkg ), opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 394fa3f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,i=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,n){var t;if(!g(r))throw new TypeError(i('1OZ3F',r));if(!m(e))throw new TypeError(i('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(i('1OZE4',e));if(arguments.length>2){if(!o(n))throw new TypeError(i('1OZAL',n));t=n}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9b67110..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0d553f2 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.3-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index bbc1dc0..62f319c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.3", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/cli-ctor": "^0.2.3", - "@stdlib/fs-read-file": "^0.2.3", - "@stdlib/process-read-stdin": "^0.2.3", - "@stdlib/streams-node-stdin": "^0.2.3", - "@stdlib/string-base-code-point-at": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-windows": "^0.2.3", - "@stdlib/constants-unicode-max": "^0.2.3", - "@stdlib/process-exec-path": "^0.2.3", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/string-from-code-point": "^0.2.3", - "@stdlib/string-replace": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..78bacc9 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From d4fce7268b8b30948d2781d2e89104eae4731fd8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 17 Jul 2026 03:18:38 +0000 Subject: [PATCH 156/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 8be14ac..bbc1dc0 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.3", "@stdlib/streams-node-stdin": "^0.2.3", "@stdlib/string-base-code-point-at": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { From 68d790267c5717d96ea4367af76942ed8614a4ff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 17 Jul 2026 03:40:15 +0000 Subject: [PATCH 157/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0d553f2..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.3-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 78bacc9..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e3a04fad6e7c499ec1f016ea2695a23b1b049e67 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 17 Jul 2026 03:40:40 +0000 Subject: [PATCH 158/161] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1044 ---- .github/workflows/publish.yml | 261 - .github/workflows/publish_cli.yml | 184 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 247 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 50 files changed, 4863 insertions(+), 5274 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 00d7b2d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-07-17T03:13:45.341Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8a3fbd5..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index a74ef1e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1044 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 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 + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8b3beca..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::built-in', pkg ), opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e8f6caa..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){try{return e||r((e={exports:{}}).exports,e),e.exports}catch(i){throw (e=0, i)}};};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,n=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,i){var t;if(!g(r))throw new TypeError(n('1OZ3F',r));if(!m(e))throw new TypeError(n('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(n('1OZE4',e));if(arguments.length>2){if(!o(i))throw new TypeError(n('1OZAL',i));t=i}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 250b662..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0d553f2 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.3-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index bbc1dc0..62f319c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.3", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/cli-ctor": "^0.2.3", - "@stdlib/fs-read-file": "^0.2.3", - "@stdlib/process-read-stdin": "^0.2.3", - "@stdlib/streams-node-stdin": "^0.2.3", - "@stdlib/string-base-code-point-at": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-windows": "^0.2.3", - "@stdlib/constants-unicode-max": "^0.2.3", - "@stdlib/process-exec-path": "^0.2.3", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/string-from-code-point": "^0.2.3", - "@stdlib/string-replace": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..78bacc9 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -}); From e43a98d5c29f604acb5b309ff04378c2e6d8465a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 22 Jul 2026 03:17:42 +0000 Subject: [PATCH 159/161] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6493992..51e021d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var base = require( '@stdlib/string-base-code-point-at' ); @@ -61,20 +61,20 @@ function codePointAt( str, idx, backward ) { var FLG; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1OZ3F', str ) ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( '1OZ7f', idx ) ); } if ( idx < 0 ) { idx += str.length; } if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) ); + throw new RangeError( format( '1OZE4', idx ) ); } if ( arguments.length > 2 ) { if ( !isBoolean( backward ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) ); + throw new TypeError( format( '1OZAL', backward ) ); } FLG = backward; } else { diff --git a/package.json b/package.json index 8be14ac..bbc1dc0 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/process-read-stdin": "^0.2.3", "@stdlib/streams-node-stdin": "^0.2.3", "@stdlib/string-base-code-point-at": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { From 4fd040fd50545f5d437304a482e0a8c1a594982d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 22 Jul 2026 03:38:49 +0000 Subject: [PATCH 160/161] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 8aa3480..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a Unicode code point from a string at specified position. -* -* @param str - input string -* @param idx - position -* @param backward - backward iteration for low surrogates (default: false) -* @throws second argument must be an integer -* @throws second argument must be a valid index -* @returns code point -* -* @example -* var str = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* str = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -declare function codePointAt( str: string, idx: number, backward?: boolean ): number; - - -// EXPORTS // - -export = codePointAt; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0d553f2..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.3-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ed749ba..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 78bacc9..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ffa9660c75b84731870611b7eccce7a9e0993b88 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 22 Jul 2026 03:39:09 +0000 Subject: [PATCH 161/161] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 1044 ---- .github/workflows/publish.yml | 261 - .github/workflows/publish_cli.yml | 184 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 247 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 109 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - bin/cli | 88 - branches.md | 60 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 34 - docs/types/test.ts | 51 - docs/usage.txt | 9 - etc/cli_opts.json | 21 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 89 - package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/fixtures/stdin_error.js.txt | 33 - test/test.cli.js | 260 - test/test.js | 181 - 50 files changed, 4863 insertions(+), 5274 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100755 bin/cli delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 docs/usage.txt delete mode 100644 etc/cli_opts.json delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/fixtures/stdin_error.js.txt delete mode 100644 test/test.cli.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index cbe1256..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-07-22T03:15:57.554Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8a3fbd5..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/string/code-point-at) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 a02713c..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/string/code-point-at) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f096f01..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: '47 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index a74ef1e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,1044 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 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 + + ```
@@ -147,78 +137,7 @@ v = codePointAt( '🌷', 1, true ); -* * * - -
- -## CLI - -
- -## Installation - -To use as a general utility, install the CLI package globally - -```bash -npm install -g @stdlib/string-code-point-at-cli -``` - -
- - - -
- -### Usage - -```text -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```bash -$ code-point-at --pos=2 अनुच्छेद -2369 -``` - -To use as a [standard stream][standard-streams], - -```bash -$ echo -n 'अनुच्छेद' | code-point-at --pos=2 -2369 -``` - -
- - - -
- @@ -251,7 +170,7 @@ $ echo -n 'अनुच्छेद' | code-point-at --pos=2 ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -328,7 +247,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point +[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string-from-code-point/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8b3beca..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var fromCodePoint = require( '@stdlib/string-from-code-point' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var UNICODE_MAX = require( '@stdlib/constants-unicode-max' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var codePointAt = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( typeof String.prototype.codePointAt !== 'function' ) -}; -var VALUES = [ - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ), - fromCodePoint( discreteUniform( 0, UNICODE_MAX ) ) -]; - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = codePointAt( VALUES[ i%VALUES.length ], 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::built-in', pkg ), opts, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = VALUES[ i%VALUES.length ].codePointAt( 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bin/cli b/bin/cli deleted file mode 100755 index e6deafd..0000000 --- a/bin/cli +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var CLI = require( '@stdlib/cli-ctor' ); -var stdin = require( '@stdlib/process-read-stdin' ); -var stdinStream = require( '@stdlib/streams-node-stdin' ); -var codePointAt = require( './../lib' ); - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -* @returns {void} -*/ -function main() { - var flags; - var args; - var cli; - var pos; - - // Create a command-line interface: - cli = new CLI({ - 'pkg': require( './../package.json' ), - 'options': require( './../etc/cli_opts.json' ), - 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }) - }); - - // Get any provided command-line options: - flags = cli.flags(); - if ( flags.help || flags.version ) { - return; - } - pos = parseInt( flags.pos, 10 ); - - // Get any provided command-line arguments: - args = cli.args(); - - // Check if we are receiving data from `stdin`... - if ( stdinStream.isTTY ) { - return console.log( codePointAt( args[ 0 ], pos, flags.backward ) ); // eslint-disable-line no-console - } - return stdin( onRead ); - - /** - * Callback invoked upon reading from `stdin`. - * - * @private - * @param {(Error|null)} error - error object - * @param {Buffer} data - data - * @returns {void} - */ - function onRead( error, data ) { - if ( error ) { - return cli.error( error ); - } - console.log( codePointAt( data.toString(), pos, flags.backward ) ); // eslint-disable-line no-console - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a5815a4..0000000 --- a/branches.md +++ /dev/null @@ -1,60 +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]). -- **cli**: [CLI][cli-url] branch for use on the command line. - -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]; -C -->|extract| G[cli]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at" -%% click B href "https://github.com/stdlib-js/string-code-point-at/tree/main" -%% click C href "https://github.com/stdlib-js/string-code-point-at/tree/production" -%% click D href "https://github.com/stdlib-js/string-code-point-at/tree/esm" -%% click E href "https://github.com/stdlib-js/string-code-point-at/tree/deno" -%% click F href "https://github.com/stdlib-js/string-code-point-at/tree/umd" -%% click G href "https://github.com/stdlib-js/string-code-point-at/tree/cli" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/code-point-at -[production-url]: https://github.com/stdlib-js/string-code-point-at/tree/production -[deno-url]: https://github.com/stdlib-js/string-code-point-at/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-code-point-at/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-code-point-at/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-code-point-at/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-code-point-at/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-code-point-at/blob/esm/README.md -[cli-url]: https://github.com/stdlib-js/string-code-point-at/tree/cli \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index b86a4cb..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import codePointAt from '../docs/types/index'; -export = codePointAt; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e8f6caa..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(r,e){return function(){try{return e||r((e={exports:{}}).exports,e),e.exports}catch(i){throw (e=0, i)}};};var u=s(function(w,a){ -var o=require('@stdlib/assert-is-boolean/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-integer/dist').isPrimitive,n=require('@stdlib/error-tools-fmtprodmsg/dist'),l=require('@stdlib/string-base-code-point-at/dist');function v(r,e,i){var t;if(!g(r))throw new TypeError(n('1OZ3F',r));if(!m(e))throw new TypeError(n('1OZ7f',e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(n('1OZE4',e));if(arguments.length>2){if(!o(i))throw new TypeError(n('1OZAL',i));t=i}else t=!1;return l(r,e,t)}a.exports=v -});var f=u();module.exports=f; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 250b662..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar base = require( '@stdlib/string-base-code-point-at' );\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\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\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must be a valid position (i.e., be within string bounds). Value: `%d`.', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a boolean. Value: `%s`.', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nmodule.exports = codePointAt;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a Unicode code point from a string at a specified position.\n*\n* @module @stdlib/string-code-point-at\n*\n* @example\n* var codePointAt = require( '@stdlib/string-code-point-at' );\n*\n* var out = codePointAt( '\u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926', 2 );\n* // returns 2369\n*\n* out = codePointAt( '\uD83C\uDF37', 1, true );\n* // returns 127799\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,mCAAoC,EAiCxD,SAASC,EAAaC,EAAKC,EAAKC,EAAW,CAC1C,IAAIC,EAEJ,GAAK,CAACR,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWH,EAAQ,kEAAmEG,CAAI,CAAE,EAEvG,GAAK,CAACJ,EAAWK,CAAI,EACpB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAI,CAAE,EAK1G,GAHKA,EAAM,IACVA,GAAOD,EAAI,QAEPC,EAAM,GAAKA,GAAOD,EAAI,OAC1B,MAAM,IAAI,WAAYH,EAAQ,2GAA4GI,CAAI,CAAE,EAEjJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACP,EAAWQ,CAAS,EACzB,MAAM,IAAI,UAAWL,EAAQ,mEAAoEK,CAAS,CAAE,EAE7GC,EAAMD,CACP,MACCC,EAAM,GAEP,OAAOL,EAAME,EAAKC,EAAKE,CAAI,CAC5B,CAKAV,EAAO,QAAUM,ICnDjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isBoolean", "isString", "isInteger", "format", "base", "codePointAt", "str", "idx", "backward", "FLG", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index befd170..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( str, idx[, backward] ) - Returns a Unicode code point from a string at a specified position. - - Parameters - ---------- - str: string - Input string. - - idx: integer - Position. If less than `0`, the string position is determined relative - to the end of the input string. - - backward: boolean (optional) - Backward iteration for low surrogates. Default: false. - - Returns - ------- - out: integer - Unicode code point. - - Examples - -------- - > var out = {{alias}}( 'last man standing', 4 ) - 32 - > out = {{alias}}( 'presidential election', 8, true ) - 116 - > out = {{alias}}( 'अनुच्छेद', 2 ) - 2369 - > out = {{alias}}( '🌷', 1, true ) - 127799 - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb4b1ca..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import codePointAt = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - codePointAt( 'last man standing', 4 ); // $ExpectType number - codePointAt( 'presidential election', 8, true ); // $ExpectType number - codePointAt( 'अनुच्छेद', 2 ); // $ExpectType number - codePointAt( '🌷', 1, true ); // $ExpectType number -} - -// The compiler throws an error if the function is provided incorrect arguments... -{ - codePointAt( false, 3 ); // $ExpectError - codePointAt( {}, 3 ); // $ExpectError - codePointAt( ( x: number ): number => x, 3 ); // $ExpectError - - codePointAt( 'string', true ); // $ExpectError - codePointAt( 'string', false ); // $ExpectError - codePointAt( 'string', {} ); // $ExpectError - codePointAt( 'string', ( x: number ): number => x ); // $ExpectError - - codePointAt( 'string', 2, {} ); // $ExpectError - codePointAt( 'string', 2, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - codePointAt(); // $ExpectError - codePointAt( 'abc' ); // $ExpectError -} diff --git a/docs/usage.txt b/docs/usage.txt deleted file mode 100644 index 7c431f1..0000000 --- a/docs/usage.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Usage: code-point-at [options] --pos= [] - -Options: - - -h, --help Print this message. - -V, --version Print the package version. - -b, --backward Backward iteration for low surrogates. - --pos index Position in string. diff --git a/etc/cli_opts.json b/etc/cli_opts.json deleted file mode 100644 index 755174f..0000000 --- a/etc/cli_opts.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "string": [ - "pos" - ], - "boolean": [ - "help", - "version", - "backward" - ], - "alias": { - "help": [ - "h" - ], - "version": [ - "V" - ], - "backward": [ - "b" - ] - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 787f5c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var codePointAt = require( './../lib' ); - -console.log( codePointAt( 'last man standing', 4 ) ); -// => 32 - -console.log( codePointAt( 'presidential election', 8, true ) ); -// => 116 - -console.log( codePointAt( 'अनुच्छेद', 2 ) ); -// => 2369 - -console.log( codePointAt( '🌷', 1, true ) ); -// => 127799 diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0d553f2 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-code-point-at@v0.2.3-esm/index.mjs";function n(n,o,m){var d;if(!t(n))throw new TypeError(r("1OZ3F",n));if(!e(o))throw new TypeError(r("1OZ7f",o));if(o<0&&(o+=n.length),o<0||o>=n.length)throw new RangeError(r("1OZE4",o));if(arguments.length>2){if(!s(m))throw new TypeError(r("1OZAL",m));d=m}else d=!1;return i(n,o,d)}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ed749ba --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport base from '@stdlib/string-base-code-point-at';\n\n\n// MAIN //\n\n/**\n* Returns a Unicode code point from a string at a specified position.\n*\n* @param {string} str - input string\n* @param {integer} idx - position\n* @param {boolean} [backward=false] - backward iteration for low surrogates\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be a boolean\n* @throws {RangeError} position must be a valid index in string\n* @returns {NonNegativeInteger} code point\n*\n* @example\n* var out = codePointAt( 'last man standing', 4 );\n* // returns 32\n*\n* @example\n* var out = codePointAt( 'presidential election', 8, true );\n* // returns 116\n*\n* @example\n* var out = codePointAt( 'अनुच्छेद', 2 );\n* // returns 2369\n*\n* @example\n* var out = codePointAt( '🌷', 1, true );\n* // returns 127799\n*/\nfunction codePointAt( str, idx, backward ) {\n\tvar FLG;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1OZ3F', str ) );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( '1OZ7f', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += str.length;\n\t}\n\tif ( idx < 0 || idx >= str.length ) {\n\t\tthrow new RangeError( format( '1OZE4', idx ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tif ( !isBoolean( backward ) ) {\n\t\t\tthrow new TypeError( format( '1OZAL', backward ) );\n\t\t}\n\t\tFLG = backward;\n\t} else {\n\t\tFLG = false;\n\t}\n\treturn base( str, idx, FLG );\n}\n\n\n// EXPORTS //\n\nexport default codePointAt;\n"],"names":["codePointAt","str","idx","backward","FLG","isString","TypeError","format","isInteger","length","RangeError","arguments","isBoolean","base"],"mappings":";;qgBA2DA,SAASA,EAAaC,EAAKC,EAAKC,GAC/B,IAAIC,EAEJ,IAAMC,EAAUJ,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAWN,GAChB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAKvC,GAHKA,EAAM,IACVA,GAAOD,EAAIQ,QAEPP,EAAM,GAAKA,GAAOD,EAAIQ,OAC1B,MAAM,IAAIC,WAAYH,EAAQ,QAASL,IAExC,GAAKS,UAAUF,OAAS,EAAI,CAC3B,IAAMG,EAAWT,GAChB,MAAM,IAAIG,UAAWC,EAAQ,QAASJ,IAEvCC,EAAMD,CACR,MACEC,GAAM,EAEP,OAAOS,EAAMZ,EAAKC,EAAKE,EACxB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d69e960..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a Unicode code point from a string at a specified position. -* -* @module @stdlib/string-code-point-at -* -* @example -* var codePointAt = require( '@stdlib/string-code-point-at' ); -* -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 51e021d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var base = require( '@stdlib/string-base-code-point-at' ); - - -// MAIN // - -/** -* Returns a Unicode code point from a string at a specified position. -* -* @param {string} str - input string -* @param {integer} idx - position -* @param {boolean} [backward=false] - backward iteration for low surrogates -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be a boolean -* @throws {RangeError} position must be a valid index in string -* @returns {NonNegativeInteger} code point -* -* @example -* var out = codePointAt( 'last man standing', 4 ); -* // returns 32 -* -* @example -* var out = codePointAt( 'presidential election', 8, true ); -* // returns 116 -* -* @example -* var out = codePointAt( 'अनुच्छेद', 2 ); -* // returns 2369 -* -* @example -* var out = codePointAt( '🌷', 1, true ); -* // returns 127799 -*/ -function codePointAt( str, idx, backward ) { - var FLG; - - if ( !isString( str ) ) { - throw new TypeError( format( '1OZ3F', str ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( '1OZ7f', idx ) ); - } - if ( idx < 0 ) { - idx += str.length; - } - if ( idx < 0 || idx >= str.length ) { - throw new RangeError( format( '1OZE4', idx ) ); - } - if ( arguments.length > 2 ) { - if ( !isBoolean( backward ) ) { - throw new TypeError( format( '1OZAL', backward ) ); - } - FLG = backward; - } else { - FLG = false; - } - return base( str, idx, FLG ); -} - - -// EXPORTS // - -module.exports = codePointAt; diff --git a/package.json b/package.json index bbc1dc0..62f319c 100644 --- a/package.json +++ b/package.json @@ -3,34 +3,8 @@ "version": "0.2.3", "description": "Return a Unicode code point from a string at a specified position.", "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" - } - ], - "bin": { - "from-code-point": "./bin/cli" - }, - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -39,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/cli-ctor": "^0.2.3", - "@stdlib/fs-read-file": "^0.2.3", - "@stdlib/process-read-stdin": "^0.2.3", - "@stdlib/streams-node-stdin": "^0.2.3", - "@stdlib/string-base-code-point-at": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-windows": "^0.2.3", - "@stdlib/constants-unicode-max": "^0.2.3", - "@stdlib/process-exec-path": "^0.2.3", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/string-from-code-point": "^0.2.3", - "@stdlib/string-replace": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "proxyquire": "^2.0.0", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..78bacc9 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/stdin_error.js.txt b/test/fixtures/stdin_error.js.txt deleted file mode 100644 index 23748a6..0000000 --- a/test/fixtures/stdin_error.js.txt +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -var proc = require( 'process' ); -var resolve = require( 'path' ).resolve; -var proxyquire = require( 'proxyquire' ); - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); - -proc.stdin.isTTY = false; - -proxyquire( fpath, { - '@stdlib/process-read-stdin': stdin -}); - -function stdin( clbk ) { - clbk( new Error( 'beep' ) ); -} diff --git a/test/test.cli.js b/test/test.cli.js deleted file mode 100644 index d4766ae..0000000 --- a/test/test.cli.js +++ /dev/null @@ -1,260 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var exec = require( 'child_process' ).exec; -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var IS_WINDOWS = require( '@stdlib/assert-is-windows' ); -var replace = require( '@stdlib/string-replace' ); -var readFileSync = require( '@stdlib/fs-read-file' ).sync; -var EXEC_PATH = require( '@stdlib/process-exec-path' ); - - -// VARIABLES // - -var fpath = resolve( __dirname, '..', 'bin', 'cli' ); -var opts = { - 'skip': IS_BROWSER || IS_WINDOWS -}; - - -// FIXTURES // - -var PKG_VERSION = require( './../package.json' ).version; - - -// TESTS // - -tape( 'command-line interface', function test( t ) { - t.ok( true, __filename ); - t.end(); -}); - -tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '--help' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) { - var expected; - var cmd; - - expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), { - 'encoding': 'utf8' - }); - cmd = [ - EXEC_PATH, - fpath, - '-h' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), expected+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '--version' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - fpath, - '-V' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' ); - } - t.end(); - } -}); - -tape( 'the command-line interface returns the code point at a specified string position', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=4\'; process.argv[ 3 ] = \'last man standing\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '32\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `--backward` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports backward iteration for low surrogates when invoked with the `-b` flag', opts, function test( t ) { - var cmd = [ - EXEC_PATH, - '-e', - '"process.stdin.isTTY = true; process.argv[ 2 ] = \'--pos=1\'; process.argv[ 3 ] = \'--backward\'; process.argv[ 4 ] = \'🌷\'; require( \''+fpath+'\' );"' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '127799\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) { - var cmd = [ - 'printf \'अनुच्छेद\'', - '|', - EXEC_PATH, - fpath, - '--pos=2' - ]; - - exec( cmd.join( ' ' ), done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.fail( error.message ); - } else { - t.strictEqual( stdout.toString(), '2369\n', 'expected value' ); - t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' ); - } - t.end(); - } -}); - -tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) { - var script; - var opts; - var cmd; - - script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), { - 'encoding': 'utf8' - }); - - // Replace single quotes with double quotes: - script = replace( script, '\'', '"' ); - - cmd = [ - EXEC_PATH, - '-e', - '\''+script+'\'' - ]; - - opts = { - 'cwd': __dirname - }; - - exec( cmd.join( ' ' ), opts, done ); - - function done( error, stdout, stderr ) { - if ( error ) { - t.pass( error.message ); - t.strictEqual( error.code, 1, 'expected exit code' ); - } - t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' ); - t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93eabba..0000000 --- a/test/test.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var codePointAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof codePointAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a string', function test( t ) { - var values; - var i; - - values = [ - -5, - 3.14, - -1.0, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not an integer', function test( t ) { - var values; - var i; - - values = [ - 'bar', - 3.14, - -3.14, - NaN, - true, - false, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a boolean', function test( t ) { - var values; - var i; - - values = [ - 'bar', - -5, - 3.14, - -1.0, - NaN, - null, - void 0, - [ 'beep', 'boop' ], - [ 1, 2, 3 ], - {}, - 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() { - codePointAt( 'foo', 0, value ); - }; - } -}); - -tape( 'the function throws an error if a provided position is not a valid index in the provided string', function test( t ) { - var values; - var i; - - values = [ - [ 'bar', 3 ], - [ 'bar', -4 ], - [ 'string', 7 ], - [ 'string', -8 ], - [ '', 0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - codePointAt( value[ 0 ], value[ 1 ] ); - }; - } -}); - -tape( 'the arity of the function is 3', function test( t ) { - t.strictEqual( codePointAt.length, 3, 'has length 3' ); - t.end(); -}); - -tape( 'the function returns the code point at a specified string position', function test( t ) { - var out; - - out = codePointAt( 'last man standing', 4 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'last man standing', -13 ); - t.strictEqual( out, 0x20, 'returns expected value' ); - - out = codePointAt( 'presidential election', 8, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'presidential election', -13, true ); - t.strictEqual( out, 0x74, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', 2 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( 'अनुच्छेद', -6 ); - t.strictEqual( out, 0x941, 'returns expected value' ); - - out = codePointAt( '🌷', 0, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - out = codePointAt( '🌷', -2, true ); - t.strictEqual( out, 0x1F337, 'returns expected value' ); - - t.end(); -});